diff options
Diffstat (limited to 'tests/auto/qml/qqmlqt')
-rw-r--r-- | tests/auto/qml/qqmlqt/tst_qqmlqt.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index 8e4849e2d6..e97ab543d1 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -637,7 +637,10 @@ void tst_qqmlqt::openUrlExternally() const QUrl htmlTestFile = testFileUrl("test.html"); QDesktopServices::setUrlHandler("test", &handler, "noteCall"); QDesktopServices::setUrlHandler(htmlTestFile.scheme(), &handler, "noteCall"); - + const auto unset = qScopeGuard([&] { + QDesktopServices::unsetUrlHandler(htmlTestFile.scheme()); + QDesktopServices::unsetUrlHandler("test"); + }); QQmlComponent component(&engine, testFileUrl("openUrlExternally.qml")); QScopedPointer<QObject> object(component.create()); QVERIFY(object != nullptr); @@ -648,9 +651,6 @@ void tst_qqmlqt::openUrlExternally() QCOMPARE(handler.called,2); QCOMPARE(handler.last, htmlTestFile); - - QDesktopServices::unsetUrlHandler("test"); - QDesktopServices::unsetUrlHandler(htmlTestFile.scheme()); } void tst_qqmlqt::openUrlExternally_pragmaLibrary() @@ -660,6 +660,10 @@ void tst_qqmlqt::openUrlExternally_pragmaLibrary() const QUrl htmlTestFile = testFileUrl("test.html"); QDesktopServices::setUrlHandler("test", &handler, "noteCall"); QDesktopServices::setUrlHandler(htmlTestFile.scheme(), &handler, "noteCall"); + const auto unset = qScopeGuard([&] { + QDesktopServices::unsetUrlHandler(htmlTestFile.scheme()); + QDesktopServices::unsetUrlHandler("test"); + }); QQmlComponent component(&engine, testFileUrl("openUrlExternally_lib.qml")); QScopedPointer<QObject> object(component.create()); @@ -671,9 +675,6 @@ void tst_qqmlqt::openUrlExternally_pragmaLibrary() QCOMPARE(handler.called,2); QCOMPARE(handler.last, htmlTestFile); - - QDesktopServices::unsetUrlHandler("test"); - QDesktopServices::unsetUrlHandler(htmlTestFile.scheme()); } void tst_qqmlqt::md5() |