JNI: pass same QJniEnvironment object to QAndroidPlatformClipboard

... registerNatives() call.

Change-Id: I42539846249880ed4a215522bdcafb3a2ffa4d14
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Assam Boudjelthia 2023-11-02 11:11:09 +02:00
parent bc8f0911a9
commit 742f45f7cf
3 changed files with 3 additions and 4 deletions

View File

@ -947,7 +947,7 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void */*reserved*/)
|| !QtAndroidMenu::registerNatives(env)
|| !QtAndroidAccessibility::registerNatives(env)
|| !QtAndroidDialogHelpers::registerNatives(env)
|| !QAndroidPlatformClipboard::registerNatives()) {
|| !QAndroidPlatformClipboard::registerNatives(env)) {
__android_log_print(ANDROID_LOG_FATAL, "Qt", "registerNatives failed");
return -1;
}

View File

@ -106,9 +106,8 @@ bool QAndroidPlatformClipboard::supportsMode(QClipboard::Mode mode) const
return QClipboard::Clipboard == mode;
}
bool QAndroidPlatformClipboard::registerNatives()
bool QAndroidPlatformClipboard::registerNatives(QJniEnvironment &env)
{
QJniEnvironment env;
bool success = env.registerNativeMethods(Traits<QtClipboardManager>::className(),
{ Q_JNI_NATIVE_SCOPED_METHOD(onClipboardDataChanged, QAndroidPlatformClipboard) });
if (!success) {

View File

@ -24,7 +24,7 @@ public:
void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard) override;
bool supportsMode(QClipboard::Mode mode) const override;
static bool registerNatives();
static bool registerNatives(QJniEnvironment &env);
private:
QMimeData *getClipboardMimeData();