-void MonolithicApplication::newClientSyncer(ClientSyncer *syncer) {
- connect(syncer, SIGNAL(startInternalCore(ClientSyncer *)), this, SLOT(startInternalCore(ClientSyncer *)));
+
+void MonolithicApplication::startInternalCore()
+{
+ if (_core) {
+ // Already started
+ return;
+ }
+
+ // Start internal core in a separate thread, so it doesn't block the UI
+ _core = new Core{};
+ _core->moveToThread(&_coreThread);
+ connect(&_coreThread, SIGNAL(started()), _core, SLOT(init()));
+ connect(&_coreThread, SIGNAL(finished()), _core, SLOT(deleteLater()));
+
+ connect(this, SIGNAL(connectInternalPeer(QPointer<InternalPeer>)), _core, SLOT(connectInternalPeer(QPointer<InternalPeer>)));
+ connect(_core, SIGNAL(sessionState(Protocol::SessionState)), Client::coreConnection(), SLOT(internalSessionStateReceived(Protocol::SessionState)));
+
+ connect(_core, SIGNAL(dbUpgradeInProgress(bool)), Client::instance(), SLOT(onDbUpgradeInProgress(bool)));
+
+ _coreThread.start();