From 2c94490b9c46aa17bf9f0f881042d85bc7dbe928 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Thu, 8 Dec 2022 10:58:58 +0100 Subject: [PATCH] do not create GUI from a random thread and show error on real error Signed-off-by: Matthieu Gallien --- src/gui/editlocallyjob.cpp | 5 +++-- src/gui/editlocallyjob.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/editlocallyjob.cpp b/src/gui/editlocallyjob.cpp index 1027243e38..69eccd62fc 100644 --- a/src/gui/editlocallyjob.cpp +++ b/src/gui/editlocallyjob.cpp @@ -37,6 +37,7 @@ EditLocallyJob::EditLocallyJob(const QString &userId, , _relPath(relPath) , _token(token) { + connect(this, &EditLocallyJob::callShowError, this, &EditLocallyJob::showError, Qt::QueuedConnection); } void EditLocallyJob::startSetup() @@ -546,8 +547,8 @@ void EditLocallyJob::openFile() // from a separate thread, or, there will be a freeze. To avoid searching for a specific folder and checking // if the VFS is enabled - we just always call it from a separate thread. QtConcurrent::run([localFilePathUrl, this]() { - if (QDesktopServices::openUrl(localFilePathUrl)) { - showError(tr("Could not open %1").arg(_fileName), tr("Please try again.")); + if (!QDesktopServices::openUrl(localFilePathUrl)) { + emit callShowError(tr("Could not open %1").arg(_fileName), tr("Please try again.")); } Systray::instance()->destroyEditFileLocallyLoadingDialog(); diff --git a/src/gui/editlocallyjob.h b/src/gui/editlocallyjob.h index 158e0fc5d2..6456492460 100644 --- a/src/gui/editlocallyjob.h +++ b/src/gui/editlocallyjob.h @@ -46,7 +46,7 @@ signals: void setupFinished(); void error(const QString &message, const QString &informativeText); void finished(); - + void callShowError(const QString &message, const QString &informativeText); public slots: void startSetup(); void startEditLocally();