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.

Change-Id: I01ec3c774d9943adb903fffd17b76673562daa8a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 60417a265a152aaa21081d8b4f2ad28c9730ca0f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-02-26 12:33:49 +01:00 committed by Qt Cherry-pick Bot
parent 2626a5bf1f
commit 410b57f9a6

View File

@ -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;
}