[gnome-documents/gnome-3-22] view: only add list renderers when view type is notified



commit f53c45e240550bcc502ba644d15c9c8495defc6f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Nov 25 16:15:39 2016 +0100

    view: only add list renderers when view type is notified
    
    This avoids potentially adding list renderers more than once.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774921

 src/view.js |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index fbea78c..286654f 100644
--- a/src/view.js
+++ b/src/view.js
@@ -377,6 +377,8 @@ const ViewContainer = new Lang.Class({
                           Lang.bind(this, this._onSelectionModeRequest));
         this.view.connect('view-selection-changed',
                           Lang.bind(this, this._onViewSelectionChanged));
+        this.view.connect('notify::view-type',
+                          Lang.bind(this, this._onViewTypeChanged));
 
         this._updateTypeForSettings();
         this._updateSortForSettings();
@@ -452,9 +454,6 @@ const ViewContainer = new Lang.Class({
     _updateTypeForSettings: function() {
         let viewType = Application.settings.get_enum('view-as');
         this.view.set_view_type(viewType);
-
-        if (viewType == Gd.MainViewType.LIST)
-            this._addListRenderers();
     },
 
     _updateSortForSettings: function() {
@@ -525,6 +524,11 @@ const ViewContainer = new Lang.Class({
         return doc;
     },
 
+    _onViewTypeChanged: function() {
+        if (this.view.view_type == Gd.MainViewType.LIST)
+            this._addListRenderers();
+    },
+
     _addListRenderers: function() {
         let listWidget = this.view.get_generic_view();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]