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 ef5ab6e006.

Pick-to: 6.7
Change-Id: I01ec3c774d9943adb903fffd17b76673562daa8a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
bb10
Thiago Macieira 2024-02-26 12:33:49 +01:00
parent 9828ddadfb
commit 60417a265a
1 changed files with 6 additions and 3 deletions

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