commit f0dc0ce102fe2f1173e36e3371c2966fb0eb9b32
parent cbb2d07744585b1ba655d3a1efe7f01889243d16
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date: Wed, 15 Sep 2021 13:52:17 +0200
Fix gui app initialzation order
Diffstat:
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/examples/plugins/gui/application.cc b/examples/plugins/gui/application.cc
@@ -15,10 +15,6 @@ Application::Application(int &argc, char **argv)
while (waitForDebbugger)
;
- qmlRegisterType<ParameterProxy>("org.clap", 1, 0, "ParameterProxy");
- qmlRegisterType<TransportProxy>("org.clap", 1, 0, "TransportProxy");
- qmlRegisterType<PluginProxy>("org.clap", 1, 0, "PluginProxy");
-
QCommandLineParser parser;
QCommandLineOption skinOpt("skin", tr("path to the skin directory"), tr("path"));
@@ -32,19 +28,22 @@ Application::Application(int &argc, char **argv)
parser.process(*this);
+ qmlRegisterType<ParameterProxy>("org.clap", 1, 0, "ParameterProxy");
+ qmlRegisterType<TransportProxy>("org.clap", 1, 0, "TransportProxy");
+ qmlRegisterType<PluginProxy>("org.clap", 1, 0, "PluginProxy");
+
_pluginProxy = new PluginProxy(this);
_transportProxy = new TransportProxy(this);
- auto qmlContext = _quickView->engine()->rootContext();
- for (const auto &str : parser.values(qmlLibOpt))
- _quickView->engine()->addImportPath(str);
- qmlContext->setContextProperty("plugin", _pluginProxy);
- qmlContext->setContextProperty("transport", _transportProxy);
-
- _quickView->setSource(parser.value(skinOpt) + "/main.qml");
+ ////////////////////////
+ // I/O initialization //
+ ////////////////////////
auto socket = parser.value(socketOpt).toULongLong();
+ _remoteChannel.reset(new clap::RemoteChannel(
+ [this](const clap::RemoteChannel::Message &msg) { onMessage(msg); }, *this, socket, false));
+
_socketReadNotifier.reset(new QSocketNotifier(socket, QSocketNotifier::Read, this));
connect(_socketReadNotifier.get(),
&QSocketNotifier::activated,
@@ -72,14 +71,21 @@ Application::Application(int &argc, char **argv)
quit();
});
- _remoteChannel.reset(new clap::RemoteChannel(
- [this](const clap::RemoteChannel::Message &msg) { onMessage(msg); }, *this, socket, false));
-
_socketReadNotifier->setEnabled(true);
_socketWriteNotifier->setEnabled(false);
_socketErrorNotifier->setEnabled(false);
- QCoreApplication::arguments();
+ ////////////////////////
+ // QML initialization //
+ ////////////////////////
+
+ auto qmlContext = _quickView->engine()->rootContext();
+ for (const auto &str : parser.values(qmlLibOpt))
+ _quickView->engine()->addImportPath(str);
+ qmlContext->setContextProperty("plugin", _pluginProxy);
+ qmlContext->setContextProperty("transport", _transportProxy);
+
+ _quickView->setSource(parser.value(skinOpt) + "/main.qml");
}
void Application::modifyFd(clap_fd_flags flags) {