From d577fe98175adad90061d527d012ba9d6903c44c Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 12 Jun 2022 17:30:59 +0300 Subject: [PATCH] delete the private QLibrary data pointer if library is unloaded, swap it otherwise Signed-off-by: Ivailo Monev --- src/core/plugin/qlibrary.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/plugin/qlibrary.cpp b/src/core/plugin/qlibrary.cpp index fb5f90b61..4d066f7bf 100644 --- a/src/core/plugin/qlibrary.cpp +++ b/src/core/plugin/qlibrary.cpp @@ -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; } } -- 2.11.0