[gnome-documents] overview: ViewContainer shouldn't hold a reference to OverviewStack



commit 2260d3dc440f5c5da076d24a5c781a778ea7a988
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu May 11 20:23:15 2017 +0200

    overview: ViewContainer shouldn't hold a reference to OverviewStack
    
    ViewContainer is a child of OverviewStack. The parent container
    inherently holds a reference to its children. Therefore, having a child
    also hold a reference to its parent makes us vulnerable to reference
    cycles.
    
    In this case, ViewContainer only needs OverviewStack to access the
    selection-mode GAction. So, let's only refer to the GAction.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782528

 src/overview.js |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/overview.js b/src/overview.js
index 896478d..53e3ec1 100644
--- a/src/overview.js
+++ b/src/overview.js
@@ -750,7 +750,6 @@ const ViewContainer = new Lang.Class({
     _init: function(overview, windowMode) {
         this._edgeHitId = 0;
         this._mode = windowMode;
-        this._overview = overview;
 
         this._model = new ViewModel(this._mode);
 
@@ -784,9 +783,9 @@ const ViewContainer = new Lang.Class({
         this.view.connect('notify::view-type',
                           Lang.bind(this, this._onViewTypeChanged));
 
-        let selectionModeAction = this._overview.getAction('selection-mode');
-        selectionModeAction.connect('notify::state', Lang.bind(this, this._onSelectionModeChanged));
-        this._onSelectionModeChanged(selectionModeAction);
+        this._selectionModeAction = overview.getAction('selection-mode');
+        this._selectionModeAction.connect('notify::state', Lang.bind(this, this._onSelectionModeChanged));
+        this._onSelectionModeChanged();
 
         Application.modeController.connect('window-mode-changed',
             Lang.bind(this, this._onWindowModeChanged));
@@ -902,7 +901,7 @@ const ViewContainer = new Lang.Class({
     },
 
     _onSelectionModeRequest: function() {
-        this._overview.getAction('selection-mode').change_state(GLib.Variant.new('b', true));
+        this._selectionModeAction.change_state(GLib.Variant.new('b', true));
     },
 
     _onItemActivated: function(widget, id, path) {
@@ -979,8 +978,8 @@ const ViewContainer = new Lang.Class({
         Application.selectionController.setSelection(newSelection);
     },
 
-    _onSelectionModeChanged: function(action) {
-        let selectionMode = action.state.get_boolean();
+    _onSelectionModeChanged: function() {
+        let selectionMode = this._selectionModeAction.state.get_boolean();
         this.view.set_selection_mode(selectionMode);
     },
 


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