From 60417a265a152aaa21081d8b4f2ad28c9730ca0f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Feb 2024 12:33:49 +0100 Subject: QLibrary: fake RLTD_NODELETE by not calling dlclose() On systems without the RTLD_NODELETE flag, simply don't call dlclose() and leak the handle. Amends ef5ab6e00664caf0af23b21593f809d718c9dfc7. Pick-to: 6.7 Change-Id: I01ec3c774d9943adb903fffd17b76673562daa8a Reviewed-by: Thiago Macieira Reviewed-by: Ivan Solovev --- src/corelib/plugin/qlibrary_unix.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/corelib/plugin/qlibrary_unix.cpp') diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index f4eee7fb94..4bbfd89cd6 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -257,8 +257,12 @@ bool QLibraryPrivate::load_sys() bool QLibraryPrivate::unload_sys() { -#if !defined(Q_OS_VXWORKS) // Unloading on VxWorks causes crashes in QtDeclarative autotests - if (dlclose(pHnd.loadAcquire())) { + bool doTryUnload = true; +#ifndef RTLD_NODELETE + if (loadHints() & QLibrary::PreventUnloadHint) + doTryUnload = false; +#endif + if (doTryUnload && dlclose(pHnd.loadAcquire())) { const char *error = dlerror(); #if defined (Q_OS_QNX) // Workaround until fixed in QNX; fixes crash in @@ -271,7 +275,6 @@ bool QLibraryPrivate::unload_sys() return false; } errorString.clear(); -#endif return true; } -- cgit v1.2.3