Package: qtbase-opensource-src / 5.7.1+dfsg-3+deb9u2

stop_unloading_plugins.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Description: stop unloading plugins in QPluginLoader and QFactoryLoader
 QPluginLoader hasn't unloaded in its destructor since Qt 5.0, but we
 missed the equivalent code in QFactoryLoader (which bypasses
 QPluginLoader). Besides, QPluginLoader::unload() was still doing
 unloading, which it won't anymore.
 .
 Not unloading plugins is Qt's policy, as decided during the 5.0
 development process and reaffirmed now in 5.6. This is due to static
 data in plugins leaking out and remaining in use past the unloading of
 the plugin, causing crashes.
 .
 This does not affect QLibrary and QLibrary::unload(). Those are meant
 for non-Qt loadable modules, so unloading them may be safe.
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=ca4d93d85ee446c5
Last-Update: 2017-01-11

--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -187,10 +187,12 @@
                     ++keyUsageCount;
                 }
             }
-            if (keyUsageCount || keys.isEmpty())
+            if (keyUsageCount || keys.isEmpty()) {
+                library->setLoadHints(QLibrary::PreventUnloadHint); // once loaded, don't unload
                 d->libraryList += library;
-            else
+            } else {
                 library->release();
+            }
         }
     }
 #else
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -154,6 +154,7 @@
     : QObject(parent), d(0), did_load(false)
 {
     setFileName(fileName);
+    setLoadHints(QLibrary::PreventUnloadHint);
 }
 
 /*!
@@ -348,7 +349,7 @@
 void QPluginLoader::setFileName(const QString &fileName)
 {
 #if defined(QT_SHARED)
-    QLibrary::LoadHints lh;
+    QLibrary::LoadHints lh = QLibrary::PreventUnloadHint;
     if (d) {
         lh = d->loadHints();
         d->release();
@@ -394,7 +395,7 @@
     \brief Give the load() function some hints on how it should behave.
 
     You can give hints on how the symbols in the plugin are
-    resolved. By default, none of the hints are set.
+    resolved. By default since Qt 5.7, QLibrary::PreventUnloadHint is set.
 
     See the documentation of QLibrary::loadHints for a complete
     description of how this property works.