mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
[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:
parent
a6a0e361c1
commit
fdc3b7c8da
5 changed files with 15 additions and 12 deletions
|
@ -667,7 +667,7 @@ void AccountSettings::slotEnableVfsCurrentFolder()
|
||||||
if (!selected.isValid() || !folder)
|
if (!selected.isValid() || !folder)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OwncloudWizard::askExperimentalVirtualFilesFeature([folder, this](bool enable) {
|
OwncloudWizard::askExperimentalVirtualFilesFeature(this, [folder, this](bool enable) {
|
||||||
if (!enable || !folder)
|
if (!enable || !folder)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -545,7 +545,7 @@ void FolderWizardSelectiveSync::virtualFilesCheckboxClicked()
|
||||||
// The click has already had an effect on the box, so if it's
|
// The click has already had an effect on the box, so if it's
|
||||||
// checked it was newly activated.
|
// checked it was newly activated.
|
||||||
if (_virtualFilesCheckBox->isChecked()) {
|
if (_virtualFilesCheckBox->isChecked()) {
|
||||||
OwncloudWizard::askExperimentalVirtualFilesFeature([this](bool enable) {
|
OwncloudWizard::askExperimentalVirtualFilesFeature(this, [this](bool enable) {
|
||||||
if (!enable)
|
if (!enable)
|
||||||
_virtualFilesCheckBox->setChecked(false);
|
_virtualFilesCheckBox->setChecked(false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -368,14 +368,16 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
|
||||||
|
|
||||||
void OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked()
|
void OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked()
|
||||||
{
|
{
|
||||||
OwncloudWizard::askExperimentalVirtualFilesFeature([this](bool enable) {
|
if (!_ui.rVirtualFileSync->isChecked()) {
|
||||||
if (!enable)
|
OwncloudWizard::askExperimentalVirtualFilesFeature(this, [this](bool enable) {
|
||||||
return;
|
if (!enable)
|
||||||
|
return;
|
||||||
|
|
||||||
_ui.lSelectiveSyncSizeLabel->setText(QString());
|
_ui.lSelectiveSyncSizeLabel->setText(QString());
|
||||||
_selectiveSyncBlacklist.clear();
|
_selectiveSyncBlacklist.clear();
|
||||||
setRadioChecked(_ui.rVirtualFileSync);
|
setRadioChecked(_ui.rVirtualFileSync);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwncloudAdvancedSetupPage::slotSyncEverythingClicked()
|
void OwncloudAdvancedSetupPage::slotSyncEverythingClicked()
|
||||||
|
|
|
@ -330,7 +330,7 @@ void OwncloudWizard::bringToTop()
|
||||||
ownCloudGui::raiseDialog(this);
|
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();
|
const auto bestVfsMode = bestAvailableVfsMode();
|
||||||
QMessageBox *msgBox = nullptr;
|
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("Enable experimental placeholder mode"), QMessageBox::AcceptRole);
|
||||||
msgBox->addButton(tr("Stay safe"), QMessageBox::RejectRole);
|
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);
|
callback(result == QMessageBox::AcceptRole);
|
||||||
msgBox->deleteLater();
|
msgBox->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
* being experimental. Calles the callback with true if enabling was
|
* being experimental. Calles the callback with true if enabling was
|
||||||
* chosen.
|
* 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?
|
// FIXME: Can those be local variables?
|
||||||
// Set from the OwncloudSetupPage, later used from OwncloudHttpCredsPage
|
// Set from the OwncloudSetupPage, later used from OwncloudHttpCredsPage
|
||||||
|
|
Loading…
Reference in a new issue