From e7d627339cc35907c0d5bb263ede10a017e0b988 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 2 Feb 2022 16:10:18 +0100 Subject: QPluginLoader: report the right load hints A default-constructed QPluginLoader erroneously reports that the load hints are empty. However, setting a filename would then automatically set the PreventUnload hint, surprising the user. Return the correct flags instead. Amends 494376f980e96339b6f1eff7c41336ca4d853065 Change-Id: I7a95964cb680afd3adf2f71ed73d2f93023238f2 Fixes: QTBUG-100416 Pick-to: 5.15 6.2 6.3 Reviewed-by: Thiago Macieira --- tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp') diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index fcce21433e..1ea48e7ded 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -349,10 +349,19 @@ void tst_QPluginLoader::loadHints() QSKIP("This test requires Qt to create shared libraries."); #endif QPluginLoader loader; - QCOMPARE(loader.loadHints(), QLibrary::LoadHints{}); //Do not crash + QCOMPARE(loader.loadHints(), QLibrary::PreventUnloadHint); //Do not crash loader.setLoadHints(QLibrary::ResolveAllSymbolsHint); + QCOMPARE(loader.loadHints(), QLibrary::ResolveAllSymbolsHint); loader.setFileName( sys_qualifiedLibraryName("theplugin")); //a plugin QCOMPARE(loader.loadHints(), QLibrary::ResolveAllSymbolsHint); + + QPluginLoader loader2; + QCOMPARE(loader2.loadHints(), QLibrary::PreventUnloadHint); + loader2.setFileName(sys_qualifiedLibraryName("theplugin")); + QCOMPARE(loader2.loadHints(), QLibrary::PreventUnloadHint); + + QPluginLoader loader3(sys_qualifiedLibraryName("theplugin")); + QCOMPARE(loader3.loadHints(), QLibrary::PreventUnloadHint); } void tst_QPluginLoader::deleteinstanceOnUnload() -- cgit v1.2.3