From e502e719267370f2920d2eb7efc14d34388ff850 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 14 Oct 2020 18:35:12 +0200 Subject: [PATCH 1/3] Emit last to avoid use after delete crash It turns out the shareDeleted() signal is connected to a function cleaning up the ShareLinkWidget holding the last shared pointer to the Share object. Since we use member variables for calling updateFolder() this would lead to using deleted objects. Just swap the call and the signal to have everything back in order. Signed-off-by: Kevin Ottens --- src/gui/sharemanager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/sharemanager.cpp b/src/gui/sharemanager.cpp index 2b8fbd4a9..87df91350 100644 --- a/src/gui/sharemanager.cpp +++ b/src/gui/sharemanager.cpp @@ -133,9 +133,8 @@ void Share::deleteShare() void Share::slotDeleted() { - emit shareDeleted(); - updateFolder(_account, _path); + emit shareDeleted(); } void Share::slotOcsError(int statusCode, const QString &message) From ecc170decc8175feb2ce1072036bc8d6284a8f8e Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 14 Oct 2020 18:37:34 +0200 Subject: [PATCH 2/3] Inform _emptyShareLinkWidget of linkShareRequiresPassword signals All the other ShareLinkWidgets process that signal (which allows to display error messages for instance) but not that one for some reason. That being said it might need to deal with an enforced password situation. Signed-off-by: Kevin Ottens --- src/gui/sharedialog.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index ca30aa4ff..cffb4e796 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -184,6 +184,10 @@ void ShareDialog::initLinkShareWidget(){ _emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this); _linkWidgetList.append(_emptyShareLinkWidget); + if (_manager) { + connect(_manager, &ShareManager::linkShareRequiresPassword, _emptyShareLinkWidget, &ShareLinkWidget::slotCreateShareRequiresPassword); + } + connect(_emptyShareLinkWidget, &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize); // connect(this, &ShareDialog::toggleAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleAnimation); connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare); From b7ea6530c5d3f3a62cdfeea8f4b1a46e671dba96 Mon Sep 17 00:00:00 2001 From: Kevin Ottens Date: Wed, 14 Oct 2020 18:41:35 +0200 Subject: [PATCH 3/3] Stop the animation if we got an error message Otherwise it would spin forever while we know we're not doing any work anymore since we got a message from the server. Signed-off-by: Kevin Ottens --- src/gui/sharelinkwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/sharelinkwidget.cpp b/src/gui/sharelinkwidget.cpp index 7882cefc7..3a2b40f70 100644 --- a/src/gui/sharelinkwidget.cpp +++ b/src/gui/sharelinkwidget.cpp @@ -401,7 +401,7 @@ void ShareLinkWidget::slotDeleteAnimationFinished() void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message) { - slotToggleAnimation(true); + slotToggleAnimation(message.isEmpty()); showPasswordOptions(true); if (!message.isEmpty()) {