From fa882a7cb91aca4574f0e939068fd37716a923c7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 4 Mar 2010 09:58:56 +0100 Subject: Avoid QString reallocation in QTextEngine Calling QString::utf16() will cause reallocation (for null-termination) if the string was created via fromRawData(). Reviewed-by: Benjamin Poulain Reviewed-by: Simon Hausmann --- src/gui/text/qtextengine.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 02eae98..b826588 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -81,7 +81,7 @@ public: void generate(int start, int length, QFont::Capitalization caps) { if ((int)caps == (int)QFont::SmallCaps) - generateScriptItemsSmallCaps(m_string.utf16(), start, length); + generateScriptItemsSmallCaps(reinterpret_cast(m_string.unicode()), start, length); else if(caps == QFont::Capitalize) generateScriptItemsCapitalize(start, length); else if(caps != QFont::MixedCase) { @@ -1434,9 +1434,7 @@ void QTextEngine::itemize() const layoutData->hasBidi = bidiItemize(const_cast(this), analysis, control); } - const ushort *unicode = layoutData->string.utf16(); - // correctly assign script, isTab and isObject to the script analysis - const ushort *uc = unicode; + const ushort *uc = reinterpret_cast(layoutData->string.unicode()); const ushort *e = uc + length; int lastScript = QUnicodeTables::Common; while (uc < e) { -- cgit v0.12 From 6f974452ec60ec03fd64bb2d12be6544435ae6be Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 4 Mar 2010 11:11:16 +0100 Subject: Doc: document what the timeout of -1 means in D-Bus Task-number: QTBUG-8729 --- src/dbus/qdbusconnection.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index ce3e1a0..abaa486 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -491,6 +491,12 @@ bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *rec its return value, which will be either of type QDBusMessage::ReplyMessage or QDBusMessage::ErrorMessage. + If no reply is received within \a timeout milliseconds, an automatic + error will be delivered indicating the expiration of the call. + The default \a timeout is -1, which will be replaced with an + implementation-defined value that is suitable for inter-process + communications (generally, 25 seconds). + See the QDBusInterface::call() function for a more friendly way of placing calls. @@ -526,9 +532,14 @@ QDBusMessage QDBusConnection::call(const QDBusMessage &message, QDBus::CallMode Sends the \a message over this connection and returns immediately. This function is suitable for method calls only. It returns an object of type QDBusPendingCall which can be used to - track the status of the reply. The \a timeout parameter is used to - determine when an auto-generated error reply may be emitted and is - also the upper limit for waiting in QDBusPendingCall::waitForFinished(). + track the status of the reply. + + If no reply is received within \a timeout milliseconds, an automatic + error will be delivered indicating the expiration of the call. The + default \a timeout is -1, which will be replaced with an + implementation-defined value that is suitable for inter-process + communications (generally, 25 seconds). This timeout is also the + upper limit for waiting in QDBusPendingCall::waitForFinished(). See the QDBusInterface::asyncCall() function for a more friendly way of placing calls. -- cgit v0.12 From 7727a4355876607a1a022ff54e2570dae883f79c Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 4 Mar 2010 11:16:16 +0100 Subject: Do not crash when loading themed icons statically We do not officially support static loading of icons. In fact they still crash for simple png cases due to missing X11 resources. But since we lazily create themed icons we can certainly avoid the crash in this case. You will not be able to use fallbacks here though, since we cannot know if a fallback should be used or not in this case. Reviewed-by: ogoffart Task-number: QTBUG-8666 --- src/gui/image/qicon.cpp | 4 +++- src/gui/image/qiconloader.cpp | 32 +++++++++++++++++++++++--------- src/gui/image/qiconloader_p.h | 2 ++ tests/auto/qicon/tst_qicon.cpp | 6 ++++++ 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index bf6eb8d..fad51f4 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -982,7 +982,9 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) icon = *cachedIcon; } - if (icon.availableSizes().isEmpty()) + // Note the qapp check is to allow lazy loading of static icons + // Supporting fallbacks will not work for this case. + if (qApp && icon.availableSizes().isEmpty()) return fallback; return icon; diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index b35e80a..72ec2e8 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -85,19 +85,30 @@ static QString fallbackTheme() } QIconLoader::QIconLoader() : - m_themeKey(1), m_supportsSvg(false) + m_themeKey(1), m_supportsSvg(false), m_initialized(false) { - m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName(); - if (m_systemTheme.isEmpty()) - m_systemTheme = fallbackTheme(); +} + +// We lazily initialize the loader to make static icons +// work. Though we do not officially support this. +void QIconLoader::ensureInitialized() +{ + if (!m_initialized) { + m_initialized = true; + + Q_ASSERT(qApp); + m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName(); + if (m_systemTheme.isEmpty()) + m_systemTheme = fallbackTheme(); #ifndef QT_NO_LIBRARY - QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid, - QLatin1String("/iconengines"), - Qt::CaseInsensitive); - if (iconFactoryLoader.keys().contains(QLatin1String("svg"))) - m_supportsSvg = true; + QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid, + QLatin1String("/iconengines"), + Qt::CaseInsensitive); + if (iconFactoryLoader.keys().contains(QLatin1String("svg"))) + m_supportsSvg = true; #endif //QT_NO_LIBRARY + } } QIconLoader *QIconLoader::instance() @@ -339,6 +350,9 @@ bool QIconLoaderEngine::hasIcon() const // Lazily load the icon void QIconLoaderEngine::ensureLoaded() { + + iconLoaderInstance()->ensureInitialized(); + if (!(iconLoaderInstance()->themeKey() == m_key)) { while (!m_entries.isEmpty()) diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index 19f2dda..a6b5f5b 100644 --- a/src/gui/image/qiconloader_p.h +++ b/src/gui/image/qiconloader_p.h @@ -169,6 +169,7 @@ public: static QIconLoader *instance(); void updateSystemTheme(); void invalidateKey() { m_themeKey++; } + void ensureInitialized(); private: QThemeIconEntries findIconHelper(const QString &themeName, @@ -176,6 +177,7 @@ private: QStringList &visited) const; uint m_themeKey; bool m_supportsSvg; + bool m_initialized; mutable QString m_userTheme; mutable QString m_systemTheme; diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index f861e40..fae9cc0 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -86,8 +86,14 @@ private slots: private: QString oldCurrentDir; + + const static QIcon staticIcon; }; +// Creating an icon statically should not cause a crash. +// But we do not officially support this. See QTBUG-8666 +const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find"); + void tst_QIcon::init() { QString srcdir(QLatin1String(SRCDIR)); -- cgit v0.12