[Wizard] Make vfs dialog blocking

Calling the callback after the receiver was deleted caused a crash
Fixes: #7709
Fixes: #7711
This commit is contained in:
Hannah von Reth 2020-11-27 09:58:57 +01:00 committed by Kevin Ottens
parent a6a0e361c1
commit fdc3b7c8da
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
5 changed files with 15 additions and 12 deletions

View file

@ -667,7 +667,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;

View file

@ -545,7 +545,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);
});

View file

@ -368,7 +368,8 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
void OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked()
{
OwncloudWizard::askExperimentalVirtualFilesFeature([this](bool enable) {
if (!_ui.rVirtualFileSync->isChecked()) {
OwncloudWizard::askExperimentalVirtualFilesFeature(this, [this](bool enable) {
if (!enable)
return;
@ -376,6 +377,7 @@ void OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked()
_selectiveSyncBlacklist.clear();
setRadioChecked(_ui.rVirtualFileSync);
});
}
}
void OwncloudAdvancedSetupPage::slotSyncEverythingClicked()

View file

@ -330,7 +330,7 @@ void OwncloudWizard::bringToTop()
ownCloudGui::raiseDialog(this);
}
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;
@ -369,7 +369,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();
});

View file

@ -82,7 +82,7 @@ public:
* 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