]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Make sure that changing the view mode does not fail
authorFrank Reininghaus <frank78ac@googlemail.com>
Sat, 22 Jun 2013 07:27:37 +0000 (09:27 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sat, 22 Jun 2013 07:27:37 +0000 (09:27 +0200)
This commit ensures that changing the view mode works even if the
.directory file in the user's KDE folder is not writable.

BUG: 318534
FIXED-IN: 4.11.0
REVIEW: 111120

src/views/dolphinview.cpp
src/views/dolphinview.h

index 303ee34af2dbf60edf5f0900d7935cc28fd135b9..e879f67fca911cc9520b95be5bb0ad346376b0b4 100644 (file)
@@ -248,9 +248,12 @@ void DolphinView::setMode(Mode mode)
     if (mode != m_mode) {
         ViewProperties props(viewPropertiesUrl());
         props.setViewMode(mode);
-        props.save();
 
-        applyViewProperties();
+        // We pass the new ViewProperties to applyViewProperties, rather than
+        // storing them on disk and letting applyViewProperties() read them
+        // from there, to prevent that changing the view mode fails if the
+        // .directory file is not writable (see bug 318534).
+        applyViewProperties(props);
     }
 }
 
@@ -1508,9 +1511,13 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
 
 void DolphinView::applyViewProperties()
 {
-    m_view->beginTransaction();
-
     const ViewProperties props(viewPropertiesUrl());
+    applyViewProperties(props);
+}
+
+void DolphinView::applyViewProperties(const ViewProperties& props)
+{
+    m_view->beginTransaction();
 
     const Mode mode = props.viewMode();
     if (m_mode != mode) {
index e5e9834b948cc55bb593c3b86784c5f2c3e55e67..86bc5c159d43702e0330a99ee031785599f7e6ab 100644 (file)
@@ -709,10 +709,17 @@ private:
 
     /**
      * Applies the view properties which are defined by the current URL
-     * to the DolphinView properties.
+     * to the DolphinView properties. The view properties are read from a
+     * .directory file either in the current directory, or in the
+     * share/apps/dolphin/view_properties/ subfolder of the user's .kde folder.
      */
     void applyViewProperties();
 
+    /**
+     * Applies the given view properties to the DolphinView.
+     */
+    void applyViewProperties(const ViewProperties& props);
+
     /**
      * Applies the m_mode property to the corresponding
      * itemlayout-property of the KItemListView.