Skip to content

Commit

Permalink
[Wizard] Make vfs dialog blocking
Browse files Browse the repository at this point in the history
Calling the callback after the receiver was deleted caused a crash
Fixes: owncloud#7709
Fixes: owncloud#7711
  • Loading branch information
TheOneRing committed Feb 3, 2020
1 parent 120c696 commit 241d60f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/7709
@@ -0,0 +1,5 @@
Bugfix: Fix crash if setup wizard is closed while the virtual file system dialog is open


https://github.com/owncloud/client/issues/7709
https://github.com/owncloud/client/issues/7711
6 changes: 2 additions & 4 deletions src/gui/accountsettings.cpp
Expand Up @@ -546,9 +546,7 @@ void AccountSettings::slotEnableVfsCurrentFolder()
if (!selected.isValid() || !folder)
return;

OwncloudWizard::askExperimentalVirtualFilesFeature([folder, this](bool enable) {
if (!enable || !folder)
return;
if (OwncloudWizard::askExperimentalVirtualFilesFeature()) {

// It is unsafe to switch on vfs while a sync is running - wait if necessary.
auto connection = std::make_shared<QMetaObject::Connection>();
Expand Down Expand Up @@ -589,7 +587,7 @@ void AccountSettings::slotEnableVfsCurrentFolder()
} else {
switchVfsOn();
}
});
}
}

void AccountSettings::slotDisableVfsCurrentFolder()
Expand Down
5 changes: 1 addition & 4 deletions src/gui/folderwizard.cpp
Expand Up @@ -538,10 +538,7 @@ void FolderWizardSelectiveSync::virtualFilesCheckboxClicked()
// The click has already had an effect on the box, so if it's
// checked it was newly activated.
if (_virtualFilesCheckBox->isChecked()) {
OwncloudWizard::askExperimentalVirtualFilesFeature([this](bool enable) {
if (!enable)
_virtualFilesCheckBox->setChecked(false);
});
_virtualFilesCheckBox->setChecked(OwncloudWizard::askExperimentalVirtualFilesFeature());
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/gui/wizard/owncloudadvancedsetuppage.cpp
Expand Up @@ -362,14 +362,11 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()

void OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked()
{
OwncloudWizard::askExperimentalVirtualFilesFeature([this](bool enable) {
if (!enable)
return;

if (OwncloudWizard::askExperimentalVirtualFilesFeature()) {
_ui.lSelectiveSyncSizeLabel->setText(QString());
_selectiveSyncBlacklist.clear();
setRadioChecked(_ui.rVirtualFileSync);
});
}
}

void OwncloudAdvancedSetupPage::slotSyncEverythingClicked()
Expand Down
10 changes: 4 additions & 6 deletions src/gui/wizard/owncloudwizard.cpp
Expand Up @@ -233,7 +233,7 @@ AbstractCredentials *OwncloudWizard::getCredentials() const
return 0;
}

void OwncloudWizard::askExperimentalVirtualFilesFeature(const std::function<void(bool enable)> &callback)
bool OwncloudWizard::askExperimentalVirtualFilesFeature()
{
const auto bestVfsMode = bestAvailableVfsMode();
QMessageBox *msgBox = nullptr;
Expand Down Expand Up @@ -272,11 +272,9 @@ void OwncloudWizard::askExperimentalVirtualFilesFeature(const std::function<void
msgBox->addButton(tr("Enable experimental placeholder mode"), QMessageBox::AcceptRole);
msgBox->addButton(tr("Stay safe"), QMessageBox::RejectRole);
}
connect(msgBox, &QMessageBox::finished, msgBox, [callback, msgBox](int result) {
callback(result == QMessageBox::AcceptRole);
msgBox->deleteLater();
});
msgBox->open();
bool out = msgBox->exec() == QMessageBox::AcceptRole;
msgBox->deleteLater();
return out;
}

} // end namespace
2 changes: 1 addition & 1 deletion src/gui/wizard/owncloudwizard.h
Expand Up @@ -74,7 +74,7 @@ class OwncloudWizard : public QWizard
* being experimental. Calles the callback with true if enabling was
* chosen.
*/
static void askExperimentalVirtualFilesFeature(const std::function<void(bool enable)> &callback);
static bool askExperimentalVirtualFilesFeature();

// FIXME: Can those be local variables?
// Set from the OwncloudSetupPage, later used from OwncloudHttpCredsPage
Expand Down

0 comments on commit 241d60f

Please sign in to comment.