Merge pull request #5253 from nextcloud/bugfix/editLocallyShouldWork

do not create GUI from a random thread and show error on real error
This commit is contained in:
Matthieu Gallien 2022-12-08 11:00:48 +01:00 committed by GitHub
commit 34d5b82fa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View 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();

View 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();