diff options
| author | Egor Maksimov <[email protected]> | 2026-03-06 09:50:02 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-03-06 09:50:02 +0000 |
| commit | 837034490b546beeb7d9a188134a2afb6f2d51b2 (patch) | |
| tree | dc8418a5a6be6fdfe50fd8612821715213a67e03 /src/dolphinviewcontainer.cpp | |
| parent | 57140431997fcda1eb709132c33965e70c75c0c3 (diff) | |
dolphinviewcontainer: Fix infinite loop in isTopMostParentFolderWritable
Certain urls lead to an infinite loop that causes dolphin to halt. Any url that starts with `file:` and the path doesn't have first `/` will lead to this. For example: `file:test` or `file:another/test`. If dolphin somehow saves this state, the program halt right at the start.
Rename the function to make its usage less confusing.
Diffstat (limited to 'src/dolphinviewcontainer.cpp')
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 379c55649..5c054eab8 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -984,16 +984,18 @@ void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel) m_view->setZoomLevel(zoomLevel); } -bool DolphinViewContainer::isTopMostParentFolderWritable(QUrl url) +bool DolphinViewContainer::isTopMostExistingParentFolderWritable(QUrl url) { Q_ASSERT(url.isLocalFile()); - while (url.isValid()) { + + while (!url.toLocalFile().isEmpty()) { url = url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); + QFileInfo info(url.toLocalFile()); + if (info.exists()) { return info.isWritable(); - } - if (info.isSymLink()) { + } else if (info.isSymLink()) { return false; } } @@ -1036,7 +1038,7 @@ void DolphinViewContainer::slotErrorMessageFromView(const QString &message, cons }); }); } - if (isTopMostParentFolderWritable(m_view->url())) { + if (isTopMostExistingParentFolderWritable(m_view->url())) { m_createFolderAction->setEnabled(true); m_createFolderAction->setToolTip(i18nc("@info:tooltip", "Create the folder at this path and open it")); } else { |
