Code

Filter effects dialog:
authornicholasbishop <nicholasbishop@users.sourceforge.net>
Sun, 12 Aug 2007 08:30:52 +0000 (08:30 +0000)
committernicholasbishop <nicholasbishop@users.sourceforge.net>
Sun, 12 Aug 2007 08:30:52 +0000 (08:30 +0000)
* Fixed bad use of tree iterators; caused crashes when drag/dropping filter primitives

src/ui/dialog/filter-effects-dialog.cpp

index fe2e8f1c6fc66283f19813fdb8d62e70080e3a0e..c871d447e494d210c90fa798f0f8d7cf3d9fd578 100644 (file)
@@ -1657,7 +1657,7 @@ void FilterEffectsDialog::PrimitiveList::sanitize_connections(const Gtk::TreeIte
 }
 
 // Reorder the filter primitives to match the list order
-void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::DragContext>&)
+void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::DragContext>& dc)
 {
     SPFilter* filter = _dialog._filter_modifier.get_selected_filter();
     int ndx = 0;
@@ -1665,12 +1665,19 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::Dra
     for(Gtk::TreeModel::iterator iter = _model->children().begin();
         iter != _model->children().end(); ++iter, ++ndx) {
         SPFilterPrimitive* prim = (*iter)[_columns.primitive];
-        if(prim) {
+        if(prim && prim == _drag_prim) {
             SP_OBJECT_REPR(prim)->setPosition(ndx);
-            if(_drag_prim == prim) {
-                sanitize_connections(iter);
-                get_selection()->select(iter);
-            }
+            break;
+        }
+    }
+
+    for(Gtk::TreeModel::iterator iter = _model->children().begin();
+        iter != _model->children().end(); ++iter, ++ndx) {
+        SPFilterPrimitive* prim = (*iter)[_columns.primitive];
+        if(prim && prim == _drag_prim) {
+            sanitize_connections(iter);
+            get_selection()->select(iter);
+            break;
         }
     }