do not create GUI from a random thread and show error on real error
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 8 Dec 2022 09:58:58 +0000 (10:58 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 8 Dec 2022 09:58:58 +0000 (10:58 +0100)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/editlocallyjob.cpp
src/gui/editlocallyjob.h

index 1027243e38214e6f13e180ea8018de66373680fd..69eccd62fcc0270cd8d69f8966e555e5ebd4004d 100644 (file)
@@ -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();
index 158e0fc5d2e736b03ad2f535458d758688c82dae..64564924602b9bfa40adc0d2062a6507060f65ff 100644 (file)
@@ -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();