Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crash in dialog that warns user about vfs and e2ee #3369

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

FlexW
Copy link

@FlexW FlexW commented May 27, 2021

Signed-off-by: Felix Weilbach felix.weilbach@nextcloud.com

I know the root cause of the problem lies in the fact that we use a pointer from a model too long, but I wanted to make this fix as non-invasive as possible.

@@ -96,6 +101,10 @@ bool showEnableE2eeWithVirtualFilesWarningDialog()
encryptButton->setText(AccountSettings::tr("Encrypt folder"));
e2eeWithVirtualFilesWarningMsgBox.exec();

SyncJournalFileRecord record;
if (!folder->journalDb()->getFileRecord(path, &record) || !record.isValid()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FlexW I think this check must be made after the dialog was closed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exec() returns if the dialog was closed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FlexW Ok. But still, is it the correct place to check for folder existence? I mean, it's the code for the warning dialog, and, it will even be removed once we get the E2EE with VFS PR in, so this check will then be gone. Is it possible that the folder gets removed during us clicking the "Encrypt" even without having a warning dialog displayed? If you know what I mean.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think the check is only necessary (and I think even then it's very rare that a user might encounter that case) when the dialog is displayed. I wanted to have it close to the dialog because then it's easier to remove it once the dialog is removed.

@mgallien
Copy link
Collaborator

/rebase

@github-actions github-actions bot force-pushed the bugfix/dont-crash-e2ee-vfs-dialog-on-folder-delete branch from 7ccdb5c to df04668 Compare May 27, 2021 13:58
@mgallien
Copy link
Collaborator

Signed-off-by: Felix Weilbach felix.weilbach@nextcloud.com

I know the root cause of the problem lies in the fact that we use a pointer from a model too long, but I wanted to make this fix as non-invasive as possible.

what would you do if you were doing the "invasive" fix ?

@FlexW
Copy link
Author

FlexW commented May 28, 2021

Signed-off-by: Felix Weilbach felix.weilbach@nextcloud.com
I know the root cause of the problem lies in the fact that we use a pointer from a model too long, but I wanted to make this fix as non-invasive as possible.

what would you do if you were doing the "invasive" fix ?

Use open() instead of exec() and move the part from AccountSettings::slotMarkSubfolderEncrypted() that encrypts the file into the signal handler of QDialog::finished(). Also I then would probably change the signature from AccountSettings:slotMarkSubfolderEncrypted() to make sure that the pointer of the model gets not used for too long.

@allexzander
Copy link
Contributor

allexzander commented May 28, 2021

Signed-off-by: Felix Weilbach felix.weilbach@nextcloud.com
I know the root cause of the problem lies in the fact that we use a pointer from a model too long, but I wanted to make this fix as non-invasive as possible.

what would you do if you were doing the "invasive" fix ?

Use open() instead of exec() and move the part from AccountSettings::slotMarkSubfolderEncrypted() that encrypts the file into the signal handler of QDialog::finished(). Also I then would probably change the signature from AccountSettings:slotMarkSubfolderEncrypted() to make sure that the pointer of the model gets not used for too long.

I am not sure we need to put so much effort into something that will later be removed. I mean, this dialog, it's a temporary solution, right?
In my opinion, we are good as long as we don't have a crash.

@mgallien
Copy link
Collaborator

Signed-off-by: Felix Weilbach felix.weilbach@nextcloud.com
I know the root cause of the problem lies in the fact that we use a pointer from a model too long, but I wanted to make this fix as non-invasive as possible.

what would you do if you were doing the "invasive" fix ?

Use open() instead of exec() and move the part from AccountSettings::slotMarkSubfolderEncrypted() that encrypts the file into the signal handler of QDialog::finished(). Also I then would probably change the signature from AccountSettings:slotMarkSubfolderEncrypted() to make sure that the pointer of the model gets not used for too long.

I am not sure we need to put so much effort into something that will later be removed. I mean, this dialog, it's a temporary solution, right?
In my opinion, we are good as long as we don't have a crash.

We should not let code we think is not good enough land because we can never know that we will for sure clean it before the next release. Once code is in, we have to live with it. The clean up is never guaranteed.

We can have priorities shift that would prevent doing the clean up.
We can have work to do on other parts and we never do the clean up.
...

@mgallien
Copy link
Collaborator

mgallien commented Jun 1, 2021

@FlexW can you please take care of using open() and having a fully safe implementation ?
I would prefer to fix the current issues in master

@FlexW FlexW force-pushed the bugfix/dont-crash-e2ee-vfs-dialog-on-folder-delete branch from df04668 to e74bc99 Compare June 8, 2021 14:00
src/gui/accountsettings.cpp Show resolved Hide resolved
src/gui/accountsettings.cpp Outdated Show resolved Hide resolved
src/gui/accountsettings.cpp Outdated Show resolved Hide resolved
src/gui/accountsettings.cpp Show resolved Hide resolved
@@ -339,21 +342,34 @@ void AccountSettings::slotMarkSubfolderEncrypted(FolderStatusModel::SubFolderInf

const auto folder = folderInfo->_folder;
Q_ASSERT(folder);
const auto path = folderInfo->_path;
const auto fileId = folderInfo->_fileId;
const auto encryptFolder = [this, fileId, folder, path] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure folder pointer cannot be made invalid before the lambda is called ?
QMessageBox::open is only window modal but maybe the account and folder can be removed via the tray main dialog ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It could make sense to pass a folder alias/name and then, request it from the FolderManager within the lambda :)

@FlexW FlexW force-pushed the bugfix/dont-crash-e2ee-vfs-dialog-on-folder-delete branch from ad2053e to d8542dd Compare June 16, 2021 14:23
Copy link
Collaborator

@mgallien mgallien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks
please clean history before merging

@FlexW
Copy link
Author

FlexW commented Jun 17, 2021

/rebase

@github-actions github-actions bot force-pushed the bugfix/dont-crash-e2ee-vfs-dialog-on-folder-delete branch from d8542dd to ee73786 Compare June 17, 2021 12:18
Felix Weilbach added 3 commits June 21, 2021 12:04
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
@FlexW FlexW force-pushed the bugfix/dont-crash-e2ee-vfs-dialog-on-folder-delete branch from ee73786 to cb5e839 Compare June 21, 2021 10:05
@nextcloud-desktop-bot
Copy link

AppImage file: Nextcloud-PR-3369-cb5e8398c4cb04778eaa2d0cfd84377eecc8906c-x86_64.AppImage

To test this change/fix you can simply download above AppImage file and test it.

Please make sure to quit your existing Nextcloud app and backup your data.

@FlexW FlexW merged commit 616725f into master Jun 21, 2021
@FlexW FlexW deleted the bugfix/dont-crash-e2ee-vfs-dialog-on-folder-delete branch June 21, 2021 10:24
@FlexW
Copy link
Author

FlexW commented Jun 21, 2021

/backport to stable-3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants