diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-25 16:12:11 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-25 16:12:11 +0200 |
commit | c7cdf3aac7ef9571ce0c0cf25a2c8455c7604451 (patch) | |
tree | ff17379a7643d47224a500714d825d561172a282 /src | |
parent | 3f64156e918a8cf5da1b68191a280f0daf3d954b (diff) | |
parent | 1e6630b54ce9a005c2cffac4dac95641838e8231 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/corelib/mimetypes/qmimeprovider.cpp
src/corelib/mimetypes/qmimetype.cpp
Change-Id: Ib483ddb6bfc380e7c8f195feca535703814c3872
Diffstat (limited to 'src')
19 files changed, 149 insertions, 398 deletions
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp index 80b6a76ecc..b259b42ac8 100644 --- a/src/corelib/mimetypes/qmimetype.cpp +++ b/src/corelib/mimetypes/qmimetype.cpp @@ -238,15 +238,15 @@ QString QMimeType::name() const /*! Returns the description of the MIME type to be displayed on user interfaces. - The system language (QLocale::system().name()) is used to select the appropriate translation. + The default language (QLocale().name()) is used to select the appropriate translation. */ QString QMimeType::comment() const { QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d); QStringList languageList; - languageList << QLocale::system().name(); - languageList << QLocale::system().uiLanguages(); + languageList << QLocale().name(); + languageList << QLocale().uiLanguages(); for (const QString &language : qAsConst(languageList)) { const QString lang = language == QLatin1String("C") ? QLatin1String("en_US") : language; const QString comm = d->localeComments.value(lang); diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 6690f28556..ce31fe9270 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -305,12 +305,11 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) lock.relock(); - if (!(d->state & Running)) - return; - - const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; - while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) - d->waitCondition.wait(&d->m_mutex); + if (d->state & Running) { + const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; + while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) + d->waitCondition.wait(&d->m_mutex); + } d->m_exceptionStore.throwPossibleException(); } diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 0b14ec31c2..878a920ffc 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -580,34 +580,11 @@ const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = { typedef QFreeList<QMutexPrivate, FreeListConstants> FreeList; // We cannot use Q_GLOBAL_STATIC because it uses QMutex -#if defined(Q_COMPILER_THREADSAFE_STATICS) +static FreeList freeList_; FreeList *freelist() { - static FreeList list; - return &list; + return &freeList_; } -#else -static QBasicAtomicPointer<FreeList> freeListPtr; - -FreeList *freelist() -{ - FreeList *local = freeListPtr.loadAcquire(); - if (!local) { - local = new FreeList; - if (!freeListPtr.testAndSetRelease(0, local)) { - delete local; - local = freeListPtr.loadAcquire(); - } - } - return local; -} - -static void qFreeListDeleter() -{ - delete freeListPtr.load(); -} -Q_DESTRUCTOR_FUNCTION(qFreeListDeleter) -#endif } QMutexPrivate *QMutexPrivate::allocate() diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index 88bfada515..9d2db61a11 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -848,7 +848,6 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const case ZeroDigit: return d->zeroDigit(); case LanguageId: - case ScriptId: case CountryId: { QString locale = QString::fromLatin1(getWinLocaleName()); QLocale::Language lang; @@ -857,12 +856,12 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const QLocalePrivate::getLangAndCountry(locale, lang, script, cntry); if (type == LanguageId) return lang; - if (type == ScriptId) - return script == QLocale::AnyScript ? fallbackUiLocale().script() : script; if (cntry == QLocale::AnyCountry) return fallbackUiLocale().country(); return cntry; } + case ScriptId: + return QVariant(QLocale::AnyScript); case MeasurementSystem: return d->measurementSystem(); case AMText: diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index f1135db307..9a75f4bc83 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -411,7 +411,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni static const struct { int key; - const char* name; + const char name[25]; } keyname[] = { //: This and all following "incomprehensible" strings in QShortcut context //: are key names. Please use the localized names appearing on actual @@ -693,8 +693,8 @@ static const struct { { Qt::Key_TouchpadOn, QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") }, { Qt::Key_TouchpadOff, QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") }, - { 0, 0 } }; +static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname; /*! \enum QKeySequence::StandardKey @@ -1179,7 +1179,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence for (int tran = 0; tran < 2; ++tran) { if (!nativeText) ++tran; - for (int i = 0; keyname[i].name; ++i) { + for (int i = 0; i < numKeyNames; ++i) { QString keyName(tran == 0 ? QCoreApplication::translate("QShortcut", keyname[i].name) : QString::fromLatin1(keyname[i].name)); @@ -1318,7 +1318,7 @@ QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat forma #if defined(Q_OS_MACX) NonSymbol: #endif - while (keyname[i].name) { + while (i < numKeyNames) { if (key == keyname[i].key) { p = nativeText ? QCoreApplication::translate("QShortcut", keyname[i].name) : QString::fromLatin1(keyname[i].name); @@ -1330,7 +1330,7 @@ NonSymbol: // fall back on the unicode representation of it... // Or else characters like Qt::Key_aring may not get displayed // (Really depends on you locale) - if (!keyname[i].name) { + if (i >= numKeyNames) { if (!QChar::requiresSurrogates(key)) { p = QChar(ushort(key)).toUpper(); } else { diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index d18847c434..41f7251277 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -183,6 +183,7 @@ void QOffscreenSurface::create() if (QThread::currentThread() != qGuiApp->thread()) qWarning("Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures."); d->offscreenWindow = new QWindow(d->screen); + d->offscreenWindow->setObjectName("QOffscreenSurface"); // Remove this window from the global list since we do not want it to be destroyed when closing the app. // The QOffscreenSurface has to be usable even after exiting the event loop. QGuiApplicationPrivate::window_list.removeOne(d->offscreenWindow); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index f061a2bf50..5f71bdaded 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -210,6 +210,8 @@ QWindow::~QWindow() { destroy(); QGuiApplicationPrivate::window_list.removeAll(this); + if (!QGuiApplicationPrivate::is_app_closing) + QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this); } void QWindowPrivate::init() diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index fe5d544dba..4f0c6d25f7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1039,46 +1039,45 @@ QByteArray QFontEngine::getSfntTable(uint tag) const return table; } -void QFontEngine::clearGlyphCache(const void *key) +void QFontEngine::clearGlyphCache(const void *context) { - for (QLinkedList<GlyphCacheEntry>::iterator it = m_glyphCaches.begin(), end = m_glyphCaches.end(); it != end; ) { - if (it->context == key) - it = m_glyphCaches.erase(it); - else - ++it; - } + m_glyphCaches.remove(context); } -void QFontEngine::setGlyphCache(const void *key, QFontEngineGlyphCache *data) +void QFontEngine::setGlyphCache(const void *context, QFontEngineGlyphCache *cache) { - Q_ASSERT(data); + Q_ASSERT(cache); - GlyphCacheEntry entry; - entry.context = key; - entry.cache = data; - if (m_glyphCaches.contains(entry)) - return; + GlyphCaches &caches = m_glyphCaches[context]; + for (GlyphCaches::const_iterator it = caches.constBegin(), end = caches.constEnd(); it != end; ++it) { + if (cache == it->cache.data()) + return; + } - // Limit the glyph caches to 4. This covers all 90 degree rotations and limits - // memory use when there is continuous or random rotation - if (m_glyphCaches.size() == 4) - m_glyphCaches.removeLast(); + // Limit the glyph caches to 4 per context. This covers all 90 degree rotations, + // and limits memory use when there is continuous or random rotation + if (caches.size() == 4) + caches.removeLast(); - m_glyphCaches.push_front(entry); + GlyphCacheEntry entry; + entry.cache = cache; + caches.push_front(entry); } -QFontEngineGlyphCache *QFontEngine::glyphCache(const void *key, GlyphFormat format, const QTransform &transform) const +QFontEngineGlyphCache *QFontEngine::glyphCache(const void *context, GlyphFormat format, const QTransform &transform) const { - for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) { - QFontEngineGlyphCache *c = it->cache.data(); - if (key == it->context - && format == c->glyphFormat() - && qtransform_equals_no_translate(c->m_transform, transform)) { - return c; - } + const QHash<const void*, GlyphCaches>::const_iterator caches = m_glyphCaches.constFind(context); + if (caches == m_glyphCaches.cend()) + return Q_NULLPTR; + + for (GlyphCaches::const_iterator it = caches->begin(), end = caches->end(); it != end; ++it) { + QFontEngineGlyphCache *cache = it->cache.data(); + if (format == cache->glyphFormat() && qtransform_equals_no_translate(cache->m_transform, transform)) + return cache; } - return 0; + + return Q_NULLPTR; } static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs) @@ -1558,12 +1557,11 @@ QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round) QFontEngine::GlyphCacheEntry::GlyphCacheEntry() - : context(0) { } QFontEngine::GlyphCacheEntry::GlyphCacheEntry(const GlyphCacheEntry &o) - : context(o.context), cache(o.cache) + : cache(o.cache) { } @@ -1573,7 +1571,6 @@ QFontEngine::GlyphCacheEntry::~GlyphCacheEntry() QFontEngine::GlyphCacheEntry &QFontEngine::GlyphCacheEntry::operator=(const GlyphCacheEntry &o) { - context = o.context; cache = o.cache; return *this; } diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 1430444c7e..132531f5bc 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -357,12 +357,11 @@ private: GlyphCacheEntry &operator=(const GlyphCacheEntry &); - const void *context; QExplicitlySharedDataPointer<QFontEngineGlyphCache> cache; - bool operator==(const GlyphCacheEntry &other) const { return context == other.context && cache == other.cache; } + bool operator==(const GlyphCacheEntry &other) const { return cache == other.cache; } }; - - mutable QLinkedList<GlyphCacheEntry> m_glyphCaches; + typedef QLinkedList<GlyphCacheEntry> GlyphCaches; + mutable QHash<const void *, GlyphCaches> m_glyphCaches; private: QVariant m_userData; diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index b0bc8a265e..59a6d107dc 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -129,6 +129,9 @@ void QNetworkManagerEngine::setupConfigurations() // Get active connections. foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) { + if (activeConnectionsList.contains(acPath.path())) + continue; + QNetworkManagerConnectionActive *activeConnection = new QNetworkManagerConnectionActive(acPath.path(),this); activeConnectionsList.insert(acPath.path(), activeConnection); @@ -141,14 +144,6 @@ void QNetworkManagerEngine::setupConfigurations() connectionInterfaces.insert(activeConnection->connection().path(),device.networkInterface()); } } - - // Get current list of access points. - foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) { - locker.unlock(); - deviceAdded(devicePath); //add all accesspoints - locker.relock(); - } - // Get connections. foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) { locker.unlock(); @@ -224,6 +219,10 @@ void QNetworkManagerEngine::disconnectFromId(const QString &id) QMutexLocker locker(&mutex); QNetworkManagerSettingsConnection *connection = connectionFromId(id); + + if (!connection) + return; + QNmSettingsMap map = connection->getSettings(); bool connectionAutoconnect = map.value("connection").value("autoconnect",true).toBool(); //if not present is true !! if (connectionAutoconnect) { //autoconnect connections will simply be reconnected by nm @@ -253,11 +252,6 @@ void QNetworkManagerEngine::requestUpdate() QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection); } -void QNetworkManagerEngine::scanFinished() -{ - QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection); -} - void QNetworkManagerEngine::interfacePropertiesChanged(const QMap<QString, QVariant> &properties) { QMutexLocker locker(&mutex); @@ -399,57 +393,6 @@ void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connecti } } -void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path) -{ - QNetworkManagerInterfaceDevice *iDevice; - iDevice = new QNetworkManagerInterfaceDevice(path.path(),this); - connect(iDevice,SIGNAL(connectionsChanged(QStringList)), - this,SLOT(deviceConnectionsChanged(QStringList))); - - interfaceDevices.insert(path.path(),iDevice); - if (iDevice->deviceType() == DEVICE_TYPE_WIFI) { - QNetworkManagerInterfaceDeviceWireless *wirelessDevice = - new QNetworkManagerInterfaceDeviceWireless(iDevice->path(),this); - - connect(wirelessDevice, SIGNAL(accessPointAdded(QString)), - this, SLOT(newAccessPoint(QString))); - connect(wirelessDevice, SIGNAL(accessPointRemoved(QString)), - this, SLOT(removeAccessPoint(QString))); - connect(wirelessDevice,SIGNAL(scanDone()),this,SLOT(scanFinished())); - wirelessDevice->setConnections(); - - wirelessDevices.insert(path.path(), wirelessDevice); - } - - if (iDevice->deviceType() == DEVICE_TYPE_ETHERNET) { - QNetworkManagerInterfaceDeviceWired *wiredDevice = - new QNetworkManagerInterfaceDeviceWired(iDevice->path(),this); - connect(wiredDevice,SIGNAL(carrierChanged(bool)),this,SLOT(wiredCarrierChanged(bool))); - wiredDevices.insert(iDevice->path(), wiredDevice); - } -} - -void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path) -{ - QMutexLocker locker(&mutex); - - if (interfaceDevices.contains(path.path())) { - locker.unlock(); - delete interfaceDevices.take(path.path()); - locker.relock(); - } - if (wirelessDevices.contains(path.path())) { - locker.unlock(); - delete wirelessDevices.take(path.path()); - locker.relock(); - } - if (wiredDevices.contains(path.path())) { - locker.unlock(); - delete wiredDevices.take(path.path()); - locker.relock(); - } -} - void QNetworkManagerEngine::wiredCarrierChanged(bool carrier) { QNetworkManagerInterfaceDeviceWired *deviceWired = qobject_cast<QNetworkManagerInterfaceDeviceWired *>(sender()); @@ -540,7 +483,7 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path, if (i.value()->deviceType() == deviceType) { QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(i.value()->path()); - if (wiredDevice->carrier()) { + if (wiredDevice && wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; } } @@ -569,7 +512,7 @@ bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath) } QNetworkManagerSettingsConnection *settingsConnection = connectionFromId(settingsPath); - if (settingsConnection->getType() == DEVICE_TYPE_MODEM) { + if (settingsConnection && settingsConnection->getType() == DEVICE_TYPE_MODEM) { return isActiveContext(settingsConnection->path()); } @@ -598,15 +541,10 @@ void QNetworkManagerEngine::removeConnection(const QString &path) emit configurationRemoved(ptr); locker.relock(); } + // add base AP back into configurations - QMapIterator<QString, QString> i(configuredAccessPoints); - while (i.hasNext()) { - i.next(); - if (i.value() == path) { - configuredAccessPoints.remove(i.key()); - newAccessPoint(i.key()); - } - } + + // removed along with all AP props code... } void QNetworkManagerEngine::updateConnection() @@ -680,114 +618,6 @@ void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher) } } -void QNetworkManagerEngine::newAccessPoint(const QString &path) -{ - QMutexLocker locker(&mutex); - QNetworkManagerInterfaceAccessPoint *accessPoint = - new QNetworkManagerInterfaceAccessPoint(path,this); - - bool okToAdd = true; - for (int i = 0; i < accessPoints.count(); ++i) { - if (accessPoints.at(i)->path() == path) { - okToAdd = false; - } - } - if (okToAdd) { - accessPoints.append(accessPoint); - } - // Check if configuration exists for connection. - if (!accessPoint->ssid().isEmpty()) { - - for (int i = 0; i < connections.count(); ++i) { - QNetworkManagerSettingsConnection *connection = connections.at(i); - const QString settingsPath = connection->path(); - - if (accessPoint->ssid() == connection->getSsid()) { - if (!configuredAccessPoints.contains(path)) { - configuredAccessPoints.insert(path,settingsPath); - } - - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.value(settingsPath); - ptr->mutex.lock(); - QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; - ptr->state = (flag | QNetworkConfiguration::Discovered); - - if (isConnectionActive(settingsPath)) - ptr->state = (flag | QNetworkConfiguration::Active); - ptr->mutex.unlock(); - - locker.unlock(); - emit configurationChanged(ptr); - return; - } - } - } - - // New access point. - QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); - - ptr->name = accessPoint->ssid(); - ptr->isValid = true; - ptr->id = path; - ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->purpose = QNetworkConfiguration::PublicPurpose; - ptr->state = QNetworkConfiguration::Undefined; - ptr->bearerType = QNetworkConfiguration::BearerWLAN; - - accessPointConfigurations.insert(ptr->id, ptr); - - locker.unlock(); - emit configurationAdded(ptr); -} - -void QNetworkManagerEngine::removeAccessPoint(const QString &path) -{ - QMutexLocker locker(&mutex); - for (int i = 0; i < accessPoints.count(); ++i) { - QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i); - if (accessPoint->path() == path) { - accessPoints.removeOne(accessPoint); - - if (configuredAccessPoints.contains(accessPoint->path())) { - // find connection and change state to Defined - configuredAccessPoints.remove(accessPoint->path()); - - for (int i = 0; i < connections.count(); ++i) { - QNetworkManagerSettingsConnection *connection = connections.at(i); - - if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet - const QString settingsPath = connection->path(); - const QString connectionId = settingsPath; - - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.value(connectionId); - ptr->mutex.lock(); - ptr->state = QNetworkConfiguration::Defined; - ptr->mutex.unlock(); - - locker.unlock(); - emit configurationChanged(ptr); - locker.relock(); - break; - } - } - } else { - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.take(path); - - if (ptr) { - locker.unlock(); - emit configurationRemoved(ptr); - locker.relock(); - } - } - delete accessPoint; - break; - } - } -} - QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &settingsPath, const QNmSettingsMap &map) { @@ -810,7 +640,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri QNetworkManagerInterfaceDevice device(devicePath.path(),this); if (device.deviceType() == DEVICE_TYPE_ETHERNET) { QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.path()); - if (wiredDevice->carrier()) { + if (wiredDevice && wiredDevice->carrier()) { cpPriv->state |= QNetworkConfiguration::Discovered; break; } @@ -1080,10 +910,6 @@ void QNetworkManagerEngine::nmRegistered(const QString &) managerInterface = new QNetworkManagerInterface(this); systemSettings = new QNetworkManagerSettings(NM_DBUS_SERVICE, this); - connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)), - this, SLOT(deviceAdded(QDBusObjectPath))); - connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)), - this, SLOT(deviceRemoved(QDBusObjectPath))); connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)), this, SLOT(activationFinished(QDBusPendingCallWatcher*))); connect(managerInterface, SIGNAL(propertiesChanged(QMap<QString,QVariant>)), diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index e8c40a881d..2de570b1ba 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -99,19 +99,12 @@ private Q_SLOTS: void interfacePropertiesChanged(const QMap<QString, QVariant> &properties); void activeConnectionPropertiesChanged(const QMap<QString, QVariant> &properties); - void deviceAdded(const QDBusObjectPath &path); - void deviceRemoved(const QDBusObjectPath &path); - void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0); void removeConnection(const QString &path); void updateConnection(); void activationFinished(QDBusPendingCallWatcher *watcher); void deviceConnectionsChanged(const QStringList &activeConnectionsList); - void newAccessPoint(const QString &path); - void removeAccessPoint(const QString &path); - void scanFinished(); - void wiredCarrierChanged(bool); void nmRegistered(const QString &serviceName = QString()); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 6c3c661db6..c8f00118bb 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -101,6 +101,21 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) QNetworkManagerInterface::~QNetworkManagerInterface() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + QLatin1String(NM_DBUS_INTERFACE), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + QLatin1String(NM_DBUS_INTERFACE), + QLatin1String("DeviceAdded"), + this,SIGNAL(deviceAdded(QDBusObjectPath))); + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + QLatin1String(NM_DBUS_PATH), + QLatin1String(NM_DBUS_INTERFACE), + QLatin1String("DeviceRemoved"), + this,SIGNAL(deviceRemoved(QDBusObjectPath))); } bool QNetworkManagerInterface::setConnections() @@ -241,28 +256,6 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q NM_DBUS_INTERFACE_ACCESS_POINT, QDBusConnection::systemBus(),parent) { - if (!isValid()) { - return; - } - PropertiesDBusInterface *accessPointPropertiesInterface = new PropertiesDBusInterface(QLatin1String(NM_DBUS_SERVICE), - dbusPathName, - DBUS_PROPERTIES_INTERFACE, - QDBusConnection::systemBus()); - - QList<QVariant> argumentList; - argumentList << QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT); - QDBusPendingReply<QVariantMap> propsReply - = accessPointPropertiesInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetAll"), - argumentList); - if (!propsReply.isError()) { - propertyMap = propsReply.value(); - } - - QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), - dbusPathName, - QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT), - QLatin1String("PropertiesChanged"), - this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint() @@ -375,6 +368,11 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_DEVICE), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QString QNetworkManagerInterfaceDevice::udi() const @@ -474,6 +472,11 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QString QNetworkManagerInterfaceDeviceWired::hwAddress() const @@ -563,77 +566,20 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("PropertiesChanged"), this,SLOT(propertiesSwap(QMap<QString,QVariant>))); - - QDBusPendingReply<QList<QDBusObjectPath> > reply - = asyncCall(QLatin1String("GetAccessPoints")); - - QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(reply); - connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(accessPointsFinished(QDBusPendingCallWatcher*))); } QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless() { -} - -void QNetworkManagerInterfaceDeviceWireless::slotAccessPointAdded(QDBusObjectPath path) -{ - if (path.path().length() > 2) - Q_EMIT accessPointAdded(path.path()); -} - -void QNetworkManagerInterfaceDeviceWireless::slotAccessPointRemoved(QDBusObjectPath path) -{ - if (path.path().length() > 2) - Q_EMIT accessPointRemoved(path.path()); + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } bool QNetworkManagerInterfaceDeviceWireless::setConnections() { - if (!isValid()) - return false; - - QDBusConnection dbusConnection = QDBusConnection::systemBus(); - bool allOk = true; - - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - interfacePath, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("AccessPointAdded"), - this, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { - allOk = false; - } - - - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - interfacePath, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("AccessPointRemoved"), - this, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) { - allOk = false; - } - - if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), - interfacePath, - QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), - QLatin1String("ScanDone"), - this, SLOT(scanIsDone()))) { - allOk = false; - } - return allOk; -} - -void QNetworkManagerInterfaceDeviceWireless::accessPointsFinished(QDBusPendingCallWatcher *watcher) -{ - QDBusPendingReply<QList<QDBusObjectPath> > reply(*watcher); - watcher->deleteLater(); - if (!reply.isError()) { - accessPointsList = reply.value(); - } - - for (int i = 0; i < accessPointsList.size(); i++) { - Q_EMIT accessPointAdded(accessPointsList.at(i).path()); - } + return true; } QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints() @@ -682,11 +628,6 @@ quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const return 0; } -void QNetworkManagerInterfaceDeviceWireless::scanIsDone() -{ - Q_EMIT scanDone(); -} - void QNetworkManagerInterfaceDeviceWireless::requestScan() { asyncCall(QLatin1String("RequestScan")); @@ -735,6 +676,12 @@ QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const Q QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_PATH_SETTINGS), + QLatin1String(NM_DBUS_IFACE_SETTINGS), + QLatin1String("NewConnection"), + this, SIGNAL(newConnection(QDBusObjectPath))); } QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const @@ -839,6 +786,16 @@ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QStri QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection() { + QDBusConnection::systemBus().disconnect(service(), + path(), + QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), + QLatin1String("Updated"), + this, SIGNAL(updated())); + QDBusConnection::systemBus().disconnect(service(), + path(), + QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), + QLatin1String("Removed"), + this, SIGNAL(slotSettingsRemoved())); } bool QNetworkManagerSettingsConnection::setConnections() @@ -995,6 +952,11 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString & QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive() { + QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE), + path(), + QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), + QLatin1String("PropertiesChanged"), + this,SLOT(propertiesSwap(QMap<QString,QVariant>))); } QDBusObjectPath QNetworkManagerConnectionActive::connection() const diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index 561bded156..65e618d15f 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -328,7 +328,6 @@ public: QObject *parent = 0); ~QNetworkManagerInterfaceDeviceWireless(); - QDBusObjectPath path() const; QList <QDBusObjectPath> getAccessPoints(); QString hwAddress() const; @@ -341,21 +340,11 @@ public: void requestScan(); Q_SIGNALS: void propertiesChanged(QMap<QString,QVariant>); - void accessPointAdded(const QString &); - void accessPointRemoved(const QString &); - void scanDone(); void propertiesReady(); - void accessPointsReady(); private Q_SLOTS: - void scanIsDone(); void propertiesSwap(QMap<QString,QVariant>); - void slotAccessPointAdded(QDBusObjectPath); - void slotAccessPointRemoved(QDBusObjectPath); - - void accessPointsFinished(QDBusPendingCallWatcher *watcher); - private: QVariantMap propertyMap; QList <QDBusObjectPath> accessPointsList; diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 37d5557794..9a077323e7 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -914,7 +914,7 @@ UIFont *uifont = [UIFont fontWithName:qfont.family().toNSString() size:qfont.pointSize()]; if (!uifont) return [NSDictionary dictionary]; - return [NSDictionary dictionaryWithObject:uifont forKey:UITextInputTextFontKey]; + return [NSDictionary dictionaryWithObject:uifont forKey:NSFontAttributeName]; } - (NSDictionary *)markedTextStyle diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.cpp b/src/plugins/platforms/winrt/qwinrtclipboard.cpp index 2811f1f018..4eb2517e14 100644 --- a/src/plugins/platforms/winrt/qwinrtclipboard.cpp +++ b/src/plugins/platforms/winrt/qwinrtclipboard.cpp @@ -146,7 +146,7 @@ void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) return; #ifndef Q_OS_WINPHONE - const QString text = data->text(); + const QString text = data ? data->text() : QString(); HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, text]() { HRESULT hr; ComPtr<IDataPackage> package; diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index d86cddab61..713ccb6556 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -198,7 +198,9 @@ void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIn QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole)); if (!dirIndex.isValid()) { - newIcon = fileSystemModel->iconProvider()->icon(QFileIconProvider::Folder); + const QFileIconProvider *provider = fileSystemModel->iconProvider(); + if (provider) + newIcon = provider->icon(QFileIconProvider::Folder); newName = QFileInfo(url.toLocalFile()).fileName(); if (!invalidUrls.contains(url)) invalidUrls.append(url); diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 5c046d0130..4cf77b7a1e 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -1002,15 +1002,17 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject } } - if (const QWidget *widget = qobject_cast<const QWidget *>(object)) { - QStyleSheetStyle *style = const_cast<QStyleSheetStyle *>(globalStyleSheetStyle); - if (!style) - style = qobject_cast<QStyleSheetStyle *>(widget->style()); - if (style) - fixupBorder(style->nativeFrameWidth(widget)); + if (hasBorder()) { + if (const QWidget *widget = qobject_cast<const QWidget *>(object)) { + QStyleSheetStyle *style = const_cast<QStyleSheetStyle *>(globalStyleSheetStyle); + if (!style) + style = qobject_cast<QStyleSheetStyle *>(widget->style()); + if (style) + fixupBorder(style->nativeFrameWidth(widget)); + } + if (border()->hasBorderImage()) + defaultBackground = QBrush(); } - if (hasBorder() && border()->hasBorderImage()) - defaultBackground = QBrush(); } QRect QRenderRule::borderRect(const QRect& r) const diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 1f4598ea14..599dfdb8b5 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1181,9 +1181,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption case CE_MenuItem: if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { // windows always has a check column, regardless whether we have an icon or not - const qreal devicePixelRatio = QWindowsXPStylePrivate::devicePixelRatio(widget); - int checkcol = qRound(qreal(25) / devicePixelRatio); - const int gutterWidth = qRound(qreal(3) / devicePixelRatio); + const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget); + int checkcol = qRound(qreal(25) * factor); + const int gutterWidth = qRound(qreal(3) * factor); { XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme, MENU_POPUPCHECKBACKGROUND, MBI_HOT); @@ -2172,8 +2172,9 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt const bool isToolTitle = false; const int height = tb->rect.height(); const int width = tb->rect.width(); - int buttonWidth = GetSystemMetrics(SM_CXSIZE) / QWindowsStylePrivate::devicePixelRatio(widget) - - int(QStyleHelper::dpiScaled(4)); + const int buttonWidth = + qRound(qreal(GetSystemMetrics(SM_CXSIZE)) * QWindowsStylePrivate::nativeMetricScaleFactor(widget) + - QStyleHelper::dpiScaled(4)); const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0; diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index ed4271505b..9fb18f63e8 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -2106,7 +2106,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op themeNumber = QWindowsXPStylePrivate::StatusTheme; partId = SP_GRIPPER; XPThemeData theme(0, p, themeNumber, partId, 0); - QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); size.rheight()--; if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) { switch (sg->corner) { @@ -2177,7 +2177,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QWindowsXPStylePrivate::ToolBarTheme, TP_SPLITBUTTONDROPDOWN); if (theme.isValid()) { - const QSize size = (theme.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); mbiw = size.width(); mbih = size.height(); } @@ -2640,10 +2640,11 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme) { const bool horizontal = flags & QStyle::State_Horizontal; - const QMargins contentsMargin = (theme->margins(theme->rect, TMT_SIZINGMARGINS) - / QWindowsStylePrivate::devicePixelRatio(widget)).toMargins(); + const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(widget); + const QMargins contentsMargin = + (theme->margins(theme->rect, TMT_SIZINGMARGINS) * factor).toMargins(); theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT; - const QSize size = (theme->size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + const QSize size = (theme->size() * factor).toSize(); const int hSpace = theme->rect.width() - size.width(); const int vSpace = theme->rect.height() - size.height(); @@ -3801,12 +3802,13 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt { XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL); if (buttontheme.isValid()) { - const qreal devicePixelRatio = QWindowsXPStylePrivate::devicePixelRatio(widget); - const QMarginsF borderSize = buttontheme.margins() / devicePixelRatio; + const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget); + const QMarginsF borderSize = buttontheme.margins() * factor; if (!borderSize.isNull()) { - const qreal margin = qreal(2) / devicePixelRatio; + const qreal margin = qreal(2) * factor; sz.rwidth() += qRound(borderSize.left() + borderSize.right() - margin); - sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin + devicePixelRatio - 1); + sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin + + qreal(1) / factor - 1); } const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1); sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget) @@ -4080,7 +4082,7 @@ QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon, XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme, WP_RESTOREBUTTON, RBS_NORMAL); if (theme.isValid()) { - const QSize size = (themeSize.size() / QWindowsStylePrivate::devicePixelRatio(widget)).toSize(); + const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize(); QPixmap pm(size); pm.fill(Qt::transparent); QPainter p(&pm); |