From b2029e9ca6c1645e85cbada1b09ba63fd1ee31ed Mon Sep 17 00:00:00 2001 From: Takumi ASAKI Date: Mon, 4 Jul 2016 13:57:09 +0900 Subject: Bearer/Connman: emit missing updateCompleted() emit missing updateCompleted() in some conditions after QNetworkConfigurationManager::updateConfigurations() is called. * There is no wifi devices. * The wifi device returns error when scan is called. Change-Id: I2668644249a0584bf43efea95348424aa64ab4a6 Reviewed-by: Lorn Potter --- src/plugins/bearer/connman/qconnmanengine.cpp | 10 +++++++--- src/plugins/bearer/connman/qconnmanengine.h | 2 +- src/plugins/bearer/connman/qconnmanservice_linux.cpp | 13 ++++++++++--- src/plugins/bearer/connman/qconnmanservice_linux_p.h | 6 +++--- 4 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index b7cc5f949c..fdedaa46dc 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -85,7 +85,7 @@ void QConnmanEngine::initialize() this, SLOT(updateServices(ConnmanMapList,QList))); connect(connmanManager,SIGNAL(servicesReady(QStringList)),this,SLOT(servicesReady(QStringList))); - connect(connmanManager,SIGNAL(scanFinished()),this,SLOT(finishedScan())); + connect(connmanManager,SIGNAL(scanFinished(bool)),this,SLOT(finishedScan(bool))); foreach (const QString &servPath, connmanManager->getServices()) { addServiceConfiguration(servPath); @@ -197,11 +197,15 @@ void QConnmanEngine::requestUpdate() void QConnmanEngine::doRequestUpdate() { - connmanManager->requestScan("wifi"); + bool scanned = connmanManager->requestScan("wifi"); + if (!scanned) + Q_EMIT updateCompleted(); } -void QConnmanEngine::finishedScan() +void QConnmanEngine::finishedScan(bool error) { + if (error) + Q_EMIT updateCompleted(); } void QConnmanEngine::updateServices(const ConnmanMapList &changed, const QList &removed) diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index 8c79b22bf9..c499886261 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -94,7 +94,7 @@ private Q_SLOTS: void updateServices(const ConnmanMapList &changed, const QList &removed); void servicesReady(const QStringList &); - void finishedScan(); + void finishedScan(bool error); void changedModem(); void serviceStateChanged(const QString &state); void configurationChange(QConnmanServiceInterface * service); diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 10d8285a4a..40bab4fda6 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -243,13 +243,16 @@ QStringList QConnmanManagerInterface::getServices() return servicesList; } -void QConnmanManagerInterface::requestScan(const QString &type) +bool QConnmanManagerInterface::requestScan(const QString &type) { + bool scanned = false; Q_FOREACH (QConnmanTechnologyInterface *tech, technologiesMap) { if (tech->type() == type) { tech->scan(); + scanned = true; } } + return scanned; } void QConnmanManagerInterface::technologyAdded(const QDBusObjectPath &path, const QVariantMap &) @@ -259,7 +262,7 @@ void QConnmanManagerInterface::technologyAdded(const QDBusObjectPath &path, cons QConnmanTechnologyInterface *tech; tech = new QConnmanTechnologyInterface(path.path(),this); technologiesMap.insert(path.path(),tech); - connect(tech,SIGNAL(scanFinished()),this,SIGNAL(scanFinished())); + connect(tech,SIGNAL(scanFinished(bool)),this,SIGNAL(scanFinished(bool))); } } @@ -495,7 +498,11 @@ void QConnmanTechnologyInterface::scan() void QConnmanTechnologyInterface::scanReply(QDBusPendingCallWatcher *call) { - Q_EMIT scanFinished(); + QDBusPendingReply props_reply = *call; + if (props_reply.isError()) { + qDebug() << props_reply.error().message(); + } + Q_EMIT scanFinished(props_reply.isError()); call->deleteLater(); } diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index 7292736e2e..b199a17af3 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -108,7 +108,7 @@ public: bool getOfflineMode(); QStringList getTechnologies(); QStringList getServices(); - void requestScan(const QString &type); + bool requestScan(const QString &type); QHash technologiesMap; @@ -119,7 +119,7 @@ Q_SIGNALS: void servicesChanged(const ConnmanMapList&, const QList &); void servicesReady(const QStringList &); - void scanFinished(); + void scanFinished(bool error); protected: void connectNotify(const QMetaMethod &signal); @@ -204,7 +204,7 @@ public: Q_SIGNALS: void propertyChanged(const QString &, const QDBusVariant &value); void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); - void scanFinished(); + void scanFinished(bool error); protected: void connectNotify(const QMetaMethod &signal); QVariant getProperty(const QString &); -- cgit v1.2.3 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') 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') 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') 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 From d12a284bbbf1192502e7dcd49031781ce9b54d01 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 3 Jun 2016 12:29:47 +0200 Subject: Windows QPA: Pass ExcludeUserInputEvents to QWSI::flushWindowSystemEvents() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User Input events flushed out by those calls have been observed to cause crashes. Task-number: QTBUG-39842 Change-Id: I950b80f2863def5b28e9fe46ef2b73aa6db2592f Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/windows/qwindowswindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index e4888d6b87..b38d7c29ae 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1480,7 +1480,7 @@ void QWindowsWindow::handleGeometryChange() QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); } if (testFlag(SynchronousGeometryChangeEvent)) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); qCDebug(lcQpaEvents) << __FUNCTION__ << this << window() << m_data.geometry; } @@ -1580,7 +1580,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, // Our tests depend on it. fireExpose(QRegion(qrectFromRECT(ps.rcPaint)), true); if (!QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); EndPaint(hwnd, &ps); return true; @@ -1644,7 +1644,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) switch (state) { case Qt::WindowMinimized: handleHidden(); - QWindowSystemInterface::flushWindowSystemEvents(); // Tell QQuickWindow to stop rendering now. + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); // Tell QQuickWindow to stop rendering now. break; case Qt::WindowMaximized: case Qt::WindowFullScreen: @@ -1667,7 +1667,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) } } if (exposeEventsSent && !QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); } break; default: @@ -1773,7 +1773,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) if (!wasSync) clearFlag(SynchronousGeometryChangeEvent); QWindowSystemInterface::handleGeometryChange(window(), r); - QWindowSystemInterface::flushWindowSystemEvents(); + QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); } else if (newState != Qt::WindowMinimized) { // Restore saved state. unsigned newStyle = m_savedStyle ? m_savedStyle : style(); -- cgit v1.2.3 From f2ef587906062706e576e376e4c6481ab192f50d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 30 Jun 2016 12:50:10 +0200 Subject: QWindow::fromWinId(): Return 0 when foreign window cannot be wrapped Change window creation code in QWindow to not assert should platform window creation fail for foreign windows. Prototypically add check to the Windows QPA plugin. [ChangeLog][Windows][Important Behavioral Changes] QWindow::fromWinId() may return 0 when passing invalid window handles. Task-number: QTBUG-41186 Change-Id: I936112607ec6e0838d36ac2a72aa88b869df5c23 Reviewed-by: Shawn Rutledge Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowsintegration.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 6142aac92e..debe6dd131 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -311,7 +311,12 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons } if (window->type() == Qt::ForeignWindow) { - QWindowsForeignWindow *result = new QWindowsForeignWindow(window, reinterpret_cast(window->winId())); + const HWND hwnd = reinterpret_cast(window->winId()); + if (!IsWindow(hwnd)) { + qWarning("Windows QPA: Invalid foreign window ID %p."); + return nullptr; + } + QWindowsForeignWindow *result = new QWindowsForeignWindow(window, hwnd); const QRect obtainedGeometry = result->geometry(); QScreen *screen = Q_NULLPTR; if (const QPlatformScreen *pScreen = result->screenForGeometry(obtainedGeometry)) -- cgit v1.2.3 From 444ba31a0a68421ee9ff7de788f6026599202455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Fri, 10 Jun 2016 00:11:35 +0200 Subject: xcb: Don't activate bypassed windows on mouse press Windows with "Qt::BypassWindowManagerHint" flag can't be activated by mouse. They can be activated only from code calling "activateWindow()" or "requestActivate()" methods. The patch applies also for "Qt::ToolTip" and "Qt::Popup" windows which have implicit "Qt::BypassWindowManagerHint" flag. The patch fixes some major issues: - don't activate tooltips on mouse press - this causes that Qt "thinks" that original windows loses its focus causing e.g. that text cursor stops blinking, - don't activate X11 tray icon - this causes that the active window looses its focus by clicking tray icon. The patch restores the Qt4 behavior. Task-number: QTBUG-53993 Change-Id: I80b226f2f5ea0ebbfe8922c90d9da9f4132e8cce Reviewed-by: Friedemann Kleint Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 0c2f0d7c4d..b5cde141f1 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2201,8 +2201,11 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in const bool isWheel = detail >= 4 && detail <= 7; if (!isWheel && window() != QGuiApplication::focusWindow()) { QWindow *w = static_cast(QObjectPrivate::get(window()))->eventReceiver(); - if (!(w->flags() & Qt::WindowDoesNotAcceptFocus)) + if (!(w->flags() & (Qt::WindowDoesNotAcceptFocus | Qt::BypassWindowManagerHint)) + && w->type() != Qt::ToolTip + && w->type() != Qt::Popup) { w->requestActivate(); + } } updateNetWmUserTime(timestamp); -- cgit v1.2.3 From 2ff1557937c398a7fb5cc7ba120e7ca3b5eacd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 24 Jun 2016 14:25:04 +0200 Subject: =?UTF-8?q?Cocoa:=20Don=E2=80=99t=20beep=20on=20return=20keypress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Limit event propagation to AA_PluginApplication Applications. Change-Id: Id56ceea8d2aacae3f2be17f5894791de4eca528e Task-number: QTBUG-54211 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qnsview.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index d4f2cf32fc..e88ae76c75 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1662,12 +1662,18 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const bool accepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)]; - // Track keyDown acceptance state for later acceptance of the keyUp. - if (accepted) + // When Qt is used to implement a plugin for a native application we + // want to propagate unhandled events to other native views. However, + // Qt does not always set the accepted state correctly (in particular + // for return key events), so do this for plugin applications only + // to prevent incorrect forwarding in the general case. + const bool shouldPropagate = QCoreApplication::testAttribute(Qt::AA_PluginApplication) && !accepted; + + // Track keyDown acceptance/forward state for later acceptance of the keyUp. + if (!shouldPropagate) m_acceptedKeyDowns.insert([nsevent keyCode]); - // Propagate the keyDown to the next responder if Qt did not accept it. - if (!accepted) + if (shouldPropagate) [super keyDown:nsevent]; } -- cgit v1.2.3