From 77fac5406295b138487291dc9577f33f2fc1caea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Kunz?= Date: Wed, 1 May 2024 08:52:18 +0200 Subject: [PATCH 1/5] KDESKTOP-778 - first try --- src/gui/drivepreferenceswidget.cpp | 22 ++++++++++++---------- src/gui/driveselectionwidget.cpp | 10 +++++----- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/gui/drivepreferenceswidget.cpp b/src/gui/drivepreferenceswidget.cpp index d9fefcd32..726af9e71 100644 --- a/src/gui/drivepreferenceswidget.cpp +++ b/src/gui/drivepreferenceswidget.cpp @@ -259,6 +259,7 @@ void DrivePreferencesWidget::setDrive(int driveDbId, bool unresolvedErrors) { updateUserInfo(); updateFoldersBlocs(); + ParametersWidget::setEnabled(!driveInfoMapIt->second.isBeingDeleted()); } void DrivePreferencesWidget::reset() { @@ -1042,18 +1043,19 @@ void DrivePreferencesWidget::onDriveBeingRemoved() { assert(driveInfoIt != _gui->driveInfoMap().cend()); driveInfoIt->second.setIsBeingDeleted(true); - // Lock all GUI drive-related actions during drive deletion. - GuiUtility::setEnabledRecursively(_mainVBox, false); - for (auto *child : findChildren()) { - GuiUtility::setEnabledRecursively(child, false); - } - - const QList folderBlocList = findChildren(folderBlocName); - for (PreferencesBlocWidget *folderBloc : folderBlocList) { - folderBloc->setToolTipsEnabled(false); - } +// // Lock all GUI drive-related actions during drive deletion. +// GuiUtility::setEnabledRecursively(_mainVBox, false); +// for (auto *child : findChildren()) { +// GuiUtility::setEnabledRecursively(child, false); +// } +// +// const QList folderBlocList = findChildren(folderBlocName); +// for (PreferencesBlocWidget *folderBloc : folderBlocList) { +// folderBloc->setToolTipsEnabled(false); +// } setCustomToolTipText(tr("This drive is being deleted.")); + ParametersWidget::setEnabled(false); update(); } diff --git a/src/gui/driveselectionwidget.cpp b/src/gui/driveselectionwidget.cpp index 4c58aafbb..fe21c09bc 100644 --- a/src/gui/driveselectionwidget.cpp +++ b/src/gui/driveselectionwidget.cpp @@ -84,7 +84,7 @@ QSize DriveSelectionWidget::sizeHint() const { void DriveSelectionWidget::clear() { _currentDriveDbId = 0; _downIconLabel->setVisible(false); - setDriveIcon(); + setDriveIcon(defaultDriveColor); retranslateUi(); } @@ -188,17 +188,17 @@ void DriveSelectionWidget::setDriveIcon() { } ExitCode exitCode; - QColor defaultDriveColor; - exitCode = GuiRequests::getDriveDefaultColor(defaultDriveColor); + QColor driveColor; + exitCode = GuiRequests::getDriveDefaultColor(driveColor); if (exitCode != ExitCodeOk) { qCWarning(lcDriveSelectionWidget()) << "Error in Requests::getDriveDefaultColor"; return; } - setDriveIcon(defaultDriveColor); + setDriveIcon(driveColor); } -void DriveSelectionWidget::setDriveIcon(const QColor &color = defaultDriveColor) { +void DriveSelectionWidget::setDriveIcon(const QColor &color) { if (_driveIconLabel) { _driveIconLabel->setPixmap( KDC::GuiUtility::getIconWithColor(":/client/resources/icons/actions/drive.svg", color).pixmap(_driveIconSize)); From 9dd8e38dd9116600e94c392210d159aa38511b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Kunz?= Date: Wed, 1 May 2024 11:10:37 +0200 Subject: [PATCH 2/5] KDESKTOP-778 - Clean up --- src/gui/drivepreferenceswidget.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/gui/drivepreferenceswidget.cpp b/src/gui/drivepreferenceswidget.cpp index 726af9e71..e866a4542 100644 --- a/src/gui/drivepreferenceswidget.cpp +++ b/src/gui/drivepreferenceswidget.cpp @@ -1043,17 +1043,6 @@ void DrivePreferencesWidget::onDriveBeingRemoved() { assert(driveInfoIt != _gui->driveInfoMap().cend()); driveInfoIt->second.setIsBeingDeleted(true); -// // Lock all GUI drive-related actions during drive deletion. -// GuiUtility::setEnabledRecursively(_mainVBox, false); -// for (auto *child : findChildren()) { -// GuiUtility::setEnabledRecursively(child, false); -// } -// -// const QList folderBlocList = findChildren(folderBlocName); -// for (PreferencesBlocWidget *folderBloc : folderBlocList) { -// folderBloc->setToolTipsEnabled(false); -// } - setCustomToolTipText(tr("This drive is being deleted.")); ParametersWidget::setEnabled(false); update(); From de788d9abe1e9dcfb9b8cdf8608cff6b616bfc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Kunz?= Date: Mon, 6 May 2024 10:34:32 +0200 Subject: [PATCH 3/5] KDESKTOP-829 - Finding corresponding node in other tree failed --- src/libsyncengine/syncpal/operationprocessor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libsyncengine/syncpal/operationprocessor.cpp b/src/libsyncengine/syncpal/operationprocessor.cpp index 62fded425..21bf93a62 100644 --- a/src/libsyncengine/syncpal/operationprocessor.cpp +++ b/src/libsyncengine/syncpal/operationprocessor.cpp @@ -81,6 +81,7 @@ std::shared_ptr OperationProcessor::correspondingNodeInOtherTree(std::shar } if (found) { dbNodeId = tmpDbNodeId; + node->setIdb(dbNodeId); } } From 1e0e2e18dcccd83793ba4c61cca710edd76bf4b3 Mon Sep 17 00:00:00 2001 From: Luc Guyot Date: Mon, 6 May 2024 10:48:33 +0200 Subject: [PATCH 4/5] Minimize changes while fixing the crash --- src/gui/drivepreferenceswidget.cpp | 16 ++++++++++++---- src/gui/guiutility.h | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gui/drivepreferenceswidget.cpp b/src/gui/drivepreferenceswidget.cpp index e866a4542..da50a0d5a 100644 --- a/src/gui/drivepreferenceswidget.cpp +++ b/src/gui/drivepreferenceswidget.cpp @@ -259,7 +259,6 @@ void DrivePreferencesWidget::setDrive(int driveDbId, bool unresolvedErrors) { updateUserInfo(); updateFoldersBlocs(); - ParametersWidget::setEnabled(!driveInfoMapIt->second.isBeingDeleted()); } void DrivePreferencesWidget::reset() { @@ -282,8 +281,8 @@ void DrivePreferencesWidget::refreshStatus() { if (const auto driveInfoMapIt = _gui->driveInfoMap().find(_driveDbId); driveInfoMapIt != _gui->driveInfoMap().cend()) { const auto &driveInfo = driveInfoMapIt->second; - if (!_mainVBox->isEnabled() && !driveInfo.isBeingDeleted()) { - // Re-enable the drive preferences widget after a deletion attempt. + if (!driveInfo.isBeingDeleted()) { + // Re-enable the drive preferences widget after a failed deletion attempt. setCustomToolTipText(""); GuiUtility::setEnabledRecursively(this, true); } @@ -1043,8 +1042,17 @@ void DrivePreferencesWidget::onDriveBeingRemoved() { assert(driveInfoIt != _gui->driveInfoMap().cend()); driveInfoIt->second.setIsBeingDeleted(true); + // Lock all GUI drive-related actions during drive deletion. + for (auto *child : findChildren()) { + GuiUtility::setEnabledRecursively(child, false); + } + + const QList folderBlocList = findChildren(folderBlocName); + for (PreferencesBlocWidget *folderBloc : folderBlocList) { + folderBloc->setToolTipsEnabled(false); + } + setCustomToolTipText(tr("This drive is being deleted.")); - ParametersWidget::setEnabled(false); update(); } diff --git a/src/gui/guiutility.h b/src/gui/guiutility.h index cfbc1a471..198c546a4 100644 --- a/src/gui/guiutility.h +++ b/src/gui/guiutility.h @@ -104,6 +104,8 @@ bool getLinuxDesktopType(QString &type, QString &version); #endif template void setEnabledRecursively(C *root, bool enabled) { + if (!root) return; + root->setEnabled(enabled); for (auto *child : root->template findChildren()) { setEnabledRecursively(child, enabled); From 1d6577f44d3f415aa7bd97e36646a25b741590c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Kunz?= Date: Mon, 6 May 2024 11:05:09 +0200 Subject: [PATCH 5/5] KDESKTOP-829 - Better solution --- src/libsyncengine/propagation/executor/executorworker.cpp | 3 +++ src/libsyncengine/syncpal/operationprocessor.cpp | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libsyncengine/propagation/executor/executorworker.cpp b/src/libsyncengine/propagation/executor/executorworker.cpp index 42d273b74..f3e25392f 100644 --- a/src/libsyncengine/propagation/executor/executorworker.cpp +++ b/src/libsyncengine/propagation/executor/executorworker.cpp @@ -2138,6 +2138,9 @@ bool ExecutorWorker::propagateCreateToDbAndTree(SyncOpPtr syncOp, const NodeId & updateTree->insertNode(node); newCorrespondingParentNode->insertChildren(node); + + // Affected node does not have a valid DB ID yet, update it + syncOp->affectedNode()->setIdb(newDbNodeId); } return true; diff --git a/src/libsyncengine/syncpal/operationprocessor.cpp b/src/libsyncengine/syncpal/operationprocessor.cpp index 21bf93a62..62fded425 100644 --- a/src/libsyncengine/syncpal/operationprocessor.cpp +++ b/src/libsyncengine/syncpal/operationprocessor.cpp @@ -81,7 +81,6 @@ std::shared_ptr OperationProcessor::correspondingNodeInOtherTree(std::shar } if (found) { dbNodeId = tmpDbNodeId; - node->setIdb(dbNodeId); } }