From 9d7fe3eb3dcb71926b3db65df835d45fc431eebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 23 Apr 2013 08:41:08 +0200 Subject: [PATCH] Fixed crashes relating to SVG icons. Creating a second QFactoryLoader for the same plugins seems to trigger an unload of the plugins loaded by the first factory loader. The QIconEngine created by the SVG icon plugin thus gets an invalid virtual table pointer, which causes a crash when attempting to call any virtual function in the QIconEngine (pixmap(), the virtual destructor, etc). Reusing a single QFactoryLoader instead fixes the crash. Task-number: QTBUG-30496 Change-Id: I80c5fa8b52ab9b0db68499f8c37fad14a1ac4f3c Reviewed-by: Friedemann Kleint --- src/gui/image/qicon.cpp | 5 +++++ src/gui/image/qiconloader.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index d73cd0aa57..45eda78397 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -483,6 +483,11 @@ void QPixmapIconEngine::virtual_hook(int id, void *data) #ifndef QT_NO_LIBRARY Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive)) + +QFactoryLoader *qt_iconEngineFactoryLoader() +{ + return loader(); +} #endif diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index c2e5161bd3..105dc26c9b 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -104,6 +104,10 @@ static inline QStringList systemIconSearchPaths() return QStringList(); } +#ifndef QT_NO_LIBRARY +extern QFactoryLoader *qt_iconEngineFactoryLoader(); // qicon.cpp +#endif + void QIconLoader::ensureInitialized() { if (!m_initialized) { @@ -116,10 +120,7 @@ void QIconLoader::ensureInitialized() if (m_systemTheme.isEmpty()) m_systemTheme = fallbackTheme(); #ifndef QT_NO_LIBRARY - QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterface_iid, - QLatin1String("/iconengines"), - Qt::CaseInsensitive); - if (iconFactoryLoader.keyMap().key(QLatin1String("svg"), -1) != -1) + if (qt_iconEngineFactoryLoader()->keyMap().key(QLatin1String("svg"), -1) != -1) m_supportsSvg = true; #endif //QT_NO_LIBRARY }