Code

disconnect signals on destroying
[inkscape.git] / src / widgets / font-selector.cpp
index ec619c50c202bf1d6f367d028de83ed1f13e5aca..6144840736a5451cf106823610fb20f67abe47a3 100644 (file)
@@ -307,7 +307,16 @@ static void sp_font_selector_style_select_row (GtkTreeSelection *selection,
 
 static void sp_font_selector_size_changed (GtkComboBox *cbox, SPFontSelector *fsel)
 {
+#if GTK_CHECK_VERSION(2,6,0)
     char *sstr = gtk_combo_box_get_active_text (GTK_COMBO_BOX (fsel->size));
+#else // GTK_CHECK_VERSION(2,6,0)
+    GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (fsel->size));
+    GtkTreeIter iter;
+    char *sstr = NULL;
+
+    if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (fsel->size), &iter) && model)
+        gtk_tree_model_get (model, &iter, 0, &sstr, -1);
+#endif // GTK_CHECK_VERSION(2,6,0)
     gfloat old_size = fsel->fontsize;
     fsel->fontsize = MAX(atof(sstr), 0.1);
     if ( fabs(fsel->fontsize-old_size) > 0.001)
@@ -383,13 +392,18 @@ GtkWidget *sp_font_selector_new()
 
 void sp_font_selector_set_font (SPFontSelector *fsel, font_instance *font, double size)
 {
-       
     if (font && (fsel->font != font || size != fsel->fontsize))
     {
             gchar family[256];
             font->Family (family, 256);
+            
+            Gtk::TreePath path;
 
-            Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (family);
+            try {
+                path = Inkscape::FontLister::get_instance()->get_row_for_font (family);
+            } catch (...) {
+                return;
+            }
 
             fsel->block_emit = TRUE;
             gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->family_treeview)), path.gobj());