OSDN Git Service

delete the private QLibrary data pointer if library is unloaded, swap it otherwise
authorIvailo Monev <xakepa10@gmail.com>
Sun, 12 Jun 2022 14:30:59 +0000 (17:30 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 12 Jun 2022 14:30:59 +0000 (17:30 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/plugin/qlibrary.cpp

index fb5f90b..4d066f7 100644 (file)
@@ -537,9 +537,16 @@ void QLibrary::setFileName(const QString &fileName)
             if (qt_debug_component()) {
                 qDebug() << "QLibrary: reusing library" << librarymatch;
             }
-            delete d_ptr;
-            d_ptr = loadedlibrary;
-            loadedlibraries->removeAt(i);
+            if (!d_ptr->pHnd) {
+                delete d_ptr;
+                d_ptr = loadedlibrary;
+                loadedlibraries->removeAt(i);
+            } else {
+                QLibraryPrivate* x_ptr = d_ptr;
+                d_ptr = loadedlibrary;
+                loadedlibraries->removeAt(i);
+                loadedlibraries->append(x_ptr);
+            }
             return;
         }
     }