[gnome-documents] documents: use a GtkTreeRowReference to hold the tree row



commit 9bd7df6f425b279ed4d2a4ec226a44225841d338
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 31 15:34:32 2011 -0400

    documents: use a GtkTreeRowReference to hold the tree row
    
    Using a GtkTreeRowReference here avoids any problems in case the tree
    path changes before an update is requested from the Document object.

 src/documents.js |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 58093b4..f2f5aef 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -649,16 +649,22 @@ DocumentModel.prototype = {
 
     documentAdded: function(doc) {
         let iter = this.model.append();
-        let treePath = this.model.get_path(iter);
 
         Gd.store_set(this.model, iter,
                      doc.id,
                      doc.title, doc.author,
                      doc.pixbuf, doc.mtime);
 
+        let treePath = this.model.get_path(iter);
+        let treeRowRef = Gtk.TreeRowReference.new(this.model, treePath);
+
         doc.connect('info-updated', Lang.bind(this,
             function() {
-                let objectIter = this.model.get_iter(treePath)[1];
+                let objectPath = treeRowRef.get_path();
+                if (!objectPath)
+                    return;
+
+                let objectIter = this.model.get_iter(objectPath)[1];
                 if (objectIter)
                     Gd.store_set(this.model, iter,
                                  doc.id,



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