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: #7709
Fixes: #7711
  • Loading branch information
TheOneRing committed Feb 11, 2020
1 parent cf77f31 commit 5770135
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 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: 6 additions & 0 deletions changelog/unreleased/7710
@@ -0,0 +1,6 @@
Bugfix: Don't show virtual file system warning again when the radio button is triggered a second time

Declining the dialog had no effect as the radio button was already checked

https://github.com/owncloud/client/issues/7710
https://github.com/owncloud/client/issues/7712
2 changes: 1 addition & 1 deletion src/gui/accountsettings.cpp
Expand Up @@ -546,7 +546,7 @@ void AccountSettings::slotEnableVfsCurrentFolder()
if (!selected.isValid() || !folder)
return;

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

Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderwizard.cpp
Expand Up @@ -538,7 +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) {
OwncloudWizard::askExperimentalVirtualFilesFeature(this, [this](bool enable) {
if (!enable)
_virtualFilesCheckBox->setChecked(false);
});
Expand Down
18 changes: 10 additions & 8 deletions src/gui/wizard/owncloudadvancedsetuppage.cpp
Expand Up @@ -362,14 +362,16 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()

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

_ui.lSelectiveSyncSizeLabel->setText(QString());
_selectiveSyncBlacklist.clear();
setRadioChecked(_ui.rVirtualFileSync);
});
if (!_ui.rVirtualFileSync->isChecked()) {
OwncloudWizard::askExperimentalVirtualFilesFeature(this, [this](bool enable) {
if (!enable)
return;

_ui.lSelectiveSyncSizeLabel->setText(QString());
_selectiveSyncBlacklist.clear();
setRadioChecked(_ui.rVirtualFileSync);
});
}
}

void OwncloudAdvancedSetupPage::slotSyncEverythingClicked()
Expand Down
5 changes: 3 additions & 2 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)
void OwncloudWizard::askExperimentalVirtualFilesFeature(QWidget *receiver, const std::function<void(bool enable)> &callback)
{
const auto bestVfsMode = bestAvailableVfsMode();
QMessageBox *msgBox = nullptr;
Expand Down Expand Up @@ -272,7 +272,8 @@ 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) {
msgBox->setParent(receiver);
connect(msgBox, &QMessageBox::finished, receiver, [callback, msgBox](int result) {
callback(result == QMessageBox::AcceptRole);
msgBox->deleteLater();
});
Expand Down
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 void askExperimentalVirtualFilesFeature(QWidget *receiver, const std::function<void(bool enable)> &callback);

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

0 comments on commit 5770135

Please sign in to comment.