Don't access qApp directly from Platform's ctor
QApplication might not be created yet, so delay it With a timer for now. Don't guarantee this will stay. Explicit init by the user might be an alternative.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "views/View_qtquick.h"
|
||||
#include <QQuickWindow>
|
||||
#include <QGuiApplication>
|
||||
#include <QTimer>
|
||||
|
||||
static KDDockWidgets::Platform_qtquick s_platformQtQuick;
|
||||
|
||||
@@ -28,9 +29,9 @@ Platform_qtquick::Platform_qtquick()
|
||||
// KDDockWidgets::registerQmlTypes(); // TODOv2
|
||||
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||
|
||||
qApp->connect(qApp, &QGuiApplication::focusObjectChanged, qApp, [this](QObject *obj) {
|
||||
ViewWrapper *wrapper = new Views::ViewWrapper_qtquick(obj);
|
||||
focusedViewChanged.emit(std::shared_ptr<ViewWrapper>(wrapper));
|
||||
// Delay call to init(), so we have a QApplication
|
||||
QTimer::singleShot(0, [this] {
|
||||
init();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,6 +39,14 @@ Platform_qtquick::~Platform_qtquick()
|
||||
{
|
||||
}
|
||||
|
||||
void Platform_qtquick::init()
|
||||
{
|
||||
qApp->connect(qApp, &QGuiApplication::focusObjectChanged, qApp, [this](QObject *obj) {
|
||||
ViewWrapper *wrapper = obj ? new Views::ViewWrapper_qtquick(obj) : nullptr;
|
||||
focusedViewChanged.emit(std::shared_ptr<ViewWrapper>(wrapper));
|
||||
});
|
||||
}
|
||||
|
||||
const char *Platform_qtquick::name() const
|
||||
{
|
||||
return "qtquick";
|
||||
|
||||
Reference in New Issue
Block a user