Fix messageHandler installation for Qt backends
This commit is contained in:
@@ -130,4 +130,4 @@ std::vector<KDDockWidgets::FrontendType> Platform::frontendTypes()
|
||||
return types;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -244,18 +244,27 @@ void Platform_qt::tests_sendEvent(Window::Ptr window, QEvent *ev) const
|
||||
qApp->sendEvent(static_cast<Window_qt *>(window.get())->qtWindow(), ev);
|
||||
}
|
||||
|
||||
void Platform_qt::installMessageHandler()
|
||||
{
|
||||
Tests::s_original = qInstallMessageHandler(Tests::fatalWarningsMessageHandler);
|
||||
}
|
||||
|
||||
void Platform_qt::uninstallMessageHandler()
|
||||
{
|
||||
if (!Tests::s_original)
|
||||
qWarning() << Q_FUNC_INFO << "No message handler was installed or the fatalWarningsMessageHandler was already uninstalled!";
|
||||
qInstallMessageHandler(Tests::s_original);
|
||||
Tests::s_original = nullptr;
|
||||
}
|
||||
|
||||
void Platform_qt::tests_initPlatform_impl()
|
||||
{
|
||||
qApp->setOrganizationName(QStringLiteral("KDAB"));
|
||||
qApp->setApplicationName(QStringLiteral("dockwidgets-unit-tests"));
|
||||
|
||||
Tests::s_original = qInstallMessageHandler(Tests::fatalWarningsMessageHandler);
|
||||
}
|
||||
|
||||
void Platform_qt::tests_deinitPlatform_impl()
|
||||
{
|
||||
qInstallMessageHandler(Tests::s_original);
|
||||
Tests::s_original = nullptr;
|
||||
delete qApp;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ public:
|
||||
void tests_initPlatform_impl() override;
|
||||
void tests_deinitPlatform_impl() override;
|
||||
void tests_wait(int ms) override;
|
||||
|
||||
static void installMessageHandler();
|
||||
static void uninstallMessageHandler();
|
||||
#endif
|
||||
protected:
|
||||
int screenNumberForQWindow(QWindow *) const;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Platform.h"
|
||||
#include "multisplitter/Item_p.h"
|
||||
#include "ViewFactory.h"
|
||||
#include "qtcommon/Platform_qt.h"
|
||||
|
||||
#include "controllers/MDILayout.h"
|
||||
#include "controllers/DropArea.h"
|
||||
@@ -100,6 +101,16 @@ static std::unique_ptr<MainWindow> createSimpleNestedMainWindow(Controllers::Doc
|
||||
return window;
|
||||
}
|
||||
|
||||
void TestDocks::initTestCase()
|
||||
{
|
||||
KDDockWidgets::Platform_qt::installMessageHandler();
|
||||
}
|
||||
|
||||
void TestDocks::cleanupTestCase()
|
||||
{
|
||||
KDDockWidgets::Platform_qt::uninstallMessageHandler();
|
||||
}
|
||||
|
||||
void TestDocks::tst_simple1()
|
||||
{
|
||||
// Simply create a MainWindow
|
||||
|
||||
@@ -26,9 +26,8 @@ class TestDocks : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public Q_SLOTS:
|
||||
void initTestCase()
|
||||
{
|
||||
}
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private Q_SLOTS:
|
||||
void tst_simple1();
|
||||
|
||||
Reference in New Issue
Block a user