[gnome-boxes] Don't crash when zooming out of a removed box



commit 6d61294d8e9104bfa1a2e8ce1b2783706bbf23f1
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jun 28 16:51:13 2012 +0200

    Don't crash when zooming out of a removed box
    
    Instead we zoom to 0,0.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679040

 src/collection-view.vala |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 1f846e7..b42561e 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -39,9 +39,14 @@ private class Boxes.CollectionView: Boxes.UI {
     private void get_item_pos (CollectionItem item, out float x, out float y) {
         Gdk.Rectangle rect;
         var path = get_path_for_item (item);
-        icon_view.get_cell_rect (path, null, out rect);
-        x = rect.x;
-        y = rect.y;
+        if (path != null) {
+            icon_view.get_cell_rect (path, null, out rect);
+            x = rect.x;
+            y = rect.y;
+        } else {
+            x = 0.0f;
+            y = 0.0f;
+        }
     }
 
     public override void ui_state_changed () {
@@ -204,8 +209,10 @@ private class Boxes.CollectionView: Boxes.UI {
         item.disconnect (pixbuf_id);
     }
 
-    private Gtk.TreePath get_path_for_item (CollectionItem item) {
+    private Gtk.TreePath? get_path_for_item (CollectionItem item) {
         var iter = item.get_data<Gtk.TreeIter?> ("iter");
+        if (iter == null)
+            return null;
         return model.get_path (iter);
     }
 



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