diff options
| -rw-r--r-- | src/dolphinviewcontainer.cpp | 12 | ||||
| -rw-r--r-- | src/dolphinviewcontainer.h | 2 |
2 files changed, 8 insertions, 6 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 { diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index 8ff1c59e0..3829a4f78 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -466,7 +466,7 @@ private: * Check if a folder can be created at url. * This method supports only local URLs. */ - bool isTopMostParentFolderWritable(QUrl url); + bool isTopMostExistingParentFolderWritable(QUrl url); protected: bool eventFilter(QObject *object, QEvent *event) override; |
