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

Fix crash when trying to open the folder creation dialog #2990

Merged
merged 1 commit into from Mar 17, 2021

Conversation

FlexW
Copy link

@FlexW FlexW commented Mar 11, 2021

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

@@ -37,7 +37,7 @@ FolderCreationDialog::FolderCreationDialog(const QString &destination, QWidget *

const QString suggestedFolderNamePrefix = QObject::tr("New folder");

const auto newFolderFullPath = _destination + "/" + suggestedFolderNamePrefix;
const QString newFolderFullPath = _destination + "/" + suggestedFolderNamePrefix;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@FlexW I am a bit confused about this because newFolderFullPath is then just passed to QDir(const QString& path) that should result in a similar implicit conversion from QStringBuilder to QString. But, if this works, let's move it forward.

Maybe @er-vin has some idea why this is happening?

Thread 1 "nextcloud" received signal SIGSEGV, Segmentation fault.
QString::size (this=0x5555567cfb50) at /usr/include/qt/QtCore/qstring.h:277
277 inline int size() const { return d->size; }

Copy link
Member

Choose a reason for hiding this comment

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

The problem is that QStringBuilder is lazy evaluated and that the temporaries used in the expression (_destination, "/" and suggestedFolderNamePrefix) are long gone when the line of the QDir ctor is reached and the conversion to QString occurs.

BTW, it was here before but it should be QLatin1Char('/') instead of "/".

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW, it was here before but it should be QLatin1Char('/') instead of "/".

@er-vin @FlexW I agree.

@FlexW FlexW force-pushed the bugfix/fix-create-folder-dialog-crash branch from 7f7b319 to 3ab717e Compare March 11, 2021 12:33
@@ -37,7 +40,9 @@ FolderCreationDialog::FolderCreationDialog(const QString &destination, QWidget *

const QString suggestedFolderNamePrefix = QObject::tr("New folder");

const auto newFolderFullPath = _destination + "/" + suggestedFolderNamePrefix;
qInfo(lcFolderCreationDialog) << "Before setting newFolderNameEdit";
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to introduce logs just for that? I mean they don't bring much value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@er-vin @FlexW Now, as we have an explanation, I guess they can be removed.

@@ -37,7 +37,7 @@ FolderCreationDialog::FolderCreationDialog(const QString &destination, QWidget *

const QString suggestedFolderNamePrefix = QObject::tr("New folder");

const auto newFolderFullPath = _destination + "/" + suggestedFolderNamePrefix;
const QString newFolderFullPath = _destination + "/" + suggestedFolderNamePrefix;
Copy link
Member

Choose a reason for hiding this comment

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

The problem is that QStringBuilder is lazy evaluated and that the temporaries used in the expression (_destination, "/" and suggestedFolderNamePrefix) are long gone when the line of the QDir ctor is reached and the conversion to QString occurs.

BTW, it was here before but it should be QLatin1Char('/') instead of "/".

The bug does seem to just appear in special compiler
constellations. We're unsure why this fix works. To better see if this
fix works or if crashes still occur, we added some logging.

Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
@FlexW FlexW force-pushed the bugfix/fix-create-folder-dialog-crash branch from 3ab717e to f4853da Compare March 17, 2021 07:43
@FlexW
Copy link
Author

FlexW commented Mar 17, 2021

Btw: I wonder if we should not remove that dialog. I can hardly image that someone uses it. Since most of the time you will create folder/files from your Explorer/Nautilus/Terminal.

@nextcloud-desktop-bot
Copy link

AppImage file: Nextcloud-PR-2990-f4853da2ab73ef7deb9b3c47028587a05ae9a117-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 2ab23e3 into master Mar 17, 2021
@FlexW FlexW deleted the bugfix/fix-create-folder-dialog-crash branch March 17, 2021 08:41
@er-vin
Copy link
Member

er-vin commented Mar 19, 2021

Btw: I wonder if we should not remove that dialog. I can hardly image that someone uses it. Since most of the time you will create folder/files from your Explorer/Nautilus/Terminal.

There's still one case (and that's why @allexzander introduced that dialog in the first place): when you want to create E2EE folders. Without this you're forced to go to the file manager, then the settings dialog. With this tiny feature you can then do everything through the settings dialog.

@allexzander
Copy link
Collaborator

Btw: I wonder if we should not remove that dialog. I can hardly image that someone uses it. Since most of the time you will create folder/files from your Explorer/Nautilus/Terminal.

@FlexW The thing is, this was a feature request. So, it would be a shame to remove a feature right after adding it ;)

@FlexW
Copy link
Author

FlexW commented Mar 19, 2021

@er-vin @allexzander Thanks for the explanation :) That makes sense.

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

Successfully merging this pull request may close these issues.

None yet

4 participants