From 6a95ba6273599fa24e79fb008e38197448c29605 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 14 Jun 2018 21:12:17 +0200 Subject: [PATCH] qtui: Show core connection dialog only after initialization Showing a blocking dialog in init() is a bad idea, because then initialization doesn't actually finish until the dialog is closed. For example, this delays the setup of the tray icon. Instead, go through the event loop before showing the initial connection dialog. --- src/qtui/mainwin.cpp | 15 ++++++++++----- src/qtui/mainwin.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 07c47a4d..00f83725 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -299,11 +299,7 @@ void MainWin::init() // restore locked state of docks QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool()); - CoreConnection *conn = Client::coreConnection(); - if (!conn->connectToCore()) { - // No autoconnect selected (or no accounts) - showCoreConnectionDlg(); - } + QTimer::singleShot(0, this, SLOT(doAutoConnect())); } @@ -1217,6 +1213,15 @@ void MainWin::saveMainToolBarStatus(bool enabled) } +void MainWin::doAutoConnect() +{ + if (!Client::coreConnection()->connectToCore()) { + // No autoconnect selected (or no accounts) + showCoreConnectionDlg(); + } +} + + void MainWin::connectedToCore() { Q_CHECK_PTR(Client::bufferViewManager()); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 6f741f55..e5b6ba21 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -135,6 +135,8 @@ private slots: void showNewTransferDlg(const QUuid &transferId); void onFullScreenToggled(); + void doAutoConnect(); + void handleCoreConnectionError(const QString &errorMsg); void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage); void handleNoSslInClient(bool *accepted); -- 2.20.1