From e6034a4740756334317ab2445b518a645930f4f4 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Wed, 20 Jul 2016 14:56:01 +0300 Subject: Make sure JNI_OnLoad is not called more than once Since Android 5.0 Google introduce a nasty bug[1] which calls JNI_OnLoad more than once. Basically every time when a library is loaded JNI_OnLoad is called if found, but it calls *again* JNI_OnLoad of its .so dependencies! So, JNI_OnLoad of libQt5Core.so gets called may times, this is not a problem as long as it's called from Qt's java delegate class loader. The problem is that the application .so file *must* be called from default class loader to allow the user to find his custom Activity/Service stuff. [1] Workaround https://code.google.com/p/android/issues/detail?id=215069 Change-Id: Ia71209658ef56056b560018597608acf7cb0f9ea Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/androidjnimain.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index ac37e7bd92..671dad98b2 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -822,6 +822,11 @@ QT_END_NAMESPACE Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void */*reserved*/) { + static bool initialized = false; + if (initialized) + return JNI_VERSION_1_6; + initialized = true; + QT_USE_NAMESPACE typedef union { JNIEnv *nativeEnvironment; -- cgit v1.2.3 From ad0d2f463a0905c4705660d96e8a514539c51d36 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 25 Jul 2016 12:37:20 +0200 Subject: Cocoa integration - fix a crash in QMacPasteboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMacPasteboard's dtor skips LazyRequest promises and this leaves pasteboard manager in broken state, since we release the pasteboard itself of the next step in destructor. As a result, not only Qt's app doing D & D (and thus via QCocoaDrag creating a stack-allocated QMacPasteboard) can die suddenly when somebody inspects a pasteboard, this 'somebody' ... can also die amazingly. So now we DO resolve promises using PasteboardResolvePromises (but we also preserve the original intent of not providing or providing empty data for lazy requests). Task-number: QTBUG-54663 Task-number: QTBUG-54832 Change-Id: I3ce90bd0a012dd3cbb30c93b2b17dce9473acb28 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qmacclipboard.h | 1 + src/plugins/platforms/cocoa/qmacclipboard.mm | 19 ++++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h index 0d1f195f48..6989a44a0e 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.h +++ b/src/plugins/platforms/cocoa/qmacclipboard.h @@ -69,6 +69,7 @@ private: uchar mime_type; mutable QPointer mime; mutable bool mac_mime_source; + bool resolvingBeforeDestruction; static OSStatus promiseKeeper(PasteboardRef, PasteboardItemID, CFStringRef, void *); void clear_helper(); public: diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index f4fd32ffd1..d0e2c39895 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -81,6 +81,7 @@ QMacPasteboard::QMacPasteboard(PasteboardRef p, uchar mt) mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL); paste = p; CFRetain(paste); + resolvingBeforeDestruction = false; } QMacPasteboard::QMacPasteboard(uchar mt) @@ -94,6 +95,7 @@ QMacPasteboard::QMacPasteboard(uchar mt) } else { qDebug("PasteBoard: Error creating pasteboard: [%d]", (int)err); } + resolvingBeforeDestruction = false; } QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt) @@ -107,23 +109,14 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt) } else { qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QCFString::toQString(name).toLatin1().constData(), (int)err); } + resolvingBeforeDestruction = false; } QMacPasteboard::~QMacPasteboard() { // commit all promises for paste after exit close - for (int i = 0; i < promises.count(); ++i) { - const Promise &promise = promises.at(i); - // At this point app teardown has started and control is somewhere in the Q[Core]Application - // destructor. Skip "lazy" promises where the application has not provided data; - // the application will generally not be in a state to provide it. - if (promise.dataRequestType == LazyRequest) - continue; - QCFString flavor = QCFString(promise.convertor->flavorFor(promise.mime)); - NSInteger pbItemId = promise.itemId; - promiseKeeper(paste, reinterpret_cast(pbItemId), flavor, this); - } - + resolvingBeforeDestruction = true; + PasteboardResolvePromises(paste); if (paste) CFRelease(paste); } @@ -175,7 +168,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id, // to request the data from the application. QVariant promiseData; if (promise.dataRequestType == LazyRequest) { - if (!promise.mimeData.isNull()) + if (!qpaste->resolvingBeforeDestruction && !promise.mimeData.isNull()) promiseData = promise.mimeData->variantData(promise.mime); } else { promiseData = promise.variantData; -- cgit v1.2.3 From 8ea6e8d525b9dd8703ebdd0938706bd9785858a4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 25 Jul 2016 08:57:47 +0200 Subject: QWindowsTheme::themeHint(): Handle special value of SPI_GETWHEELSCROLLLINES When the mouse wheel step is set to "Scroll one screen", querying SPI_GETWHEELSCROLLLINES returns the special value unsigned(-1). Return the default instead of converting it to int in that case since Qt does not implement it. Task-number: QTBUG-52384 Change-Id: I793e5c09103fe0c7c4a378aba97e9f63ae1c2f35 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowstheme.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index ce0c69f9ed..40be4fa31f 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -401,8 +401,13 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false)); case ContextMenuOnMouseRelease: return QVariant(true); - case WheelScrollLines: - return QVariant(int(dWordSystemParametersInfo(SPI_GETWHEELSCROLLLINES, 3))); + case WheelScrollLines: { + int result = 3; + const DWORD scrollLines = dWordSystemParametersInfo(SPI_GETWHEELSCROLLLINES, DWORD(result)); + if (scrollLines != DWORD(-1)) // Special value meaning "scroll one screen", unimplemented in Qt. + result = int(scrollLines); + return QVariant(result); + } default: break; } -- cgit v1.2.3