Fix #8028 - language server performance, fix warnings and critical errors
[roobuilder] / src / Builder4 / MainWindow.vala
index 6b62b11..adb3f8c 100644 (file)
@@ -90,7 +90,10 @@ public class Xcls_MainWindow : Object
                         BuilderApplication.removeWindow(this);
                         
                         if (BuilderApplication.windows.size  < 1) {
-                               this.windowstate.file.getLanguageServer().exit();
+                               try {
+                                       this.windowstate.file.getLanguageServer().exit();
+                               } catch(Error e) {}
+                               
                                BuilderApplication.singleton(  null ).quit();
                         }
                        return true;
@@ -1535,12 +1538,11 @@ public class Xcls_MainWindow : Object
                                if (!_this.treescroll.el.visible || _this.treeselmodel.el.get_n_items() < 0) {
                                        return;
                                }
-                               GLib.debug(
-                               
-                                       "searcj key release %d, %d, %d  ?= %d" , 
-                                               (int) keyval, (int)  keycode, state,
-                                               (int)Gdk.Key.Return
-                                       );
+                               //GLib.debug(
+                               //      "searcj key release %d, %d, %d  ?= %d" , 
+                               //              (int) keyval, (int)  keycode, state,
+                               //              (int)Gdk.Key.Return
+                               //      );
                                if (!_this.treescroll.el.visible || _this.treeselmodel.el.get_n_items() < 0) {
                                        return;
                                }
@@ -2178,19 +2180,34 @@ public class Xcls_MainWindow : Object
 
                        //listeners
                        this.el.setup.connect( (listitem) => {
+                       
+                               var li = (listitem as Gtk.ListItem);
+                               if (li == null) {
+                                       return;
+                               }
+                       
                                var lbl = new Gtk.Label("");
-                               (listitem as Gtk.ListItem).set_child(lbl);
+                               li.set_child(lbl);
                                lbl.justify = Gtk.Justification.LEFT;
                                lbl.xalign = 0;
                                lbl.use_markup = true;
                                lbl.ellipsize = Pango.EllipsizeMode.START;
                          
-                               (listitem as Gtk.ListItem).activatable = true;
+                               li.activatable = true;
                        });
                        this.el.bind.connect( (listitem) => {
-                                var lb = (Gtk.Label) (listitem as Gtk.ListItem).get_child();
-                                var item =  (listitem as Gtk.ListItem).get_item() as WindowState;
-                                
+                               var li = (listitem as Gtk.ListItem);
+                               if (li == null) {
+                                       return;
+                               }
+                                var lb = (Gtk.Label) li.get_child() as Gtk.Label;
+                                if (lb == null) {
+                                       return;
+                               }
+                                var item =  li.get_item() as WindowState;
+                                if (item == null) {
+                                       return;
+                               }
                                 lb.label = item.project.name;
                        
                        
@@ -2250,20 +2267,36 @@ public class Xcls_MainWindow : Object
 
                        //listeners
                        this.el.setup.connect( (listitem) => {
+                               var li = (listitem as Gtk.ListItem);
+                               if (li == null) {
+                                       return;
+                               }
                                var lbl = new Gtk.Label("");
-                               (listitem as Gtk.ListItem).set_child(lbl);
+                               li.set_child(lbl);
                                lbl.justify = Gtk.Justification.LEFT;
                                lbl.xalign = 0;
                                lbl.use_markup = true;
                                lbl.ellipsize = Pango.EllipsizeMode.START;
                          
-                               (listitem as Gtk.ListItem).activatable = true;
+                               li.activatable = true;
                        });
                        this.el.bind.connect( (listitem) => {
-                        var lb = (Gtk.Label) (listitem as Gtk.ListItem).get_child();
-                        var item =  (listitem as Gtk.ListItem).get_item() as WindowState;
-                        
-                        lb.label = item.file.relpath;
+                               var li = (listitem as Gtk.ListItem);
+                               if (li == null) {
+                                       return;
+                               }
+                                var lb = (Gtk.Label) li.get_child() as Gtk.Label;
+                                if (lb == null) {
+                                       return;
+                               }
+                                var item =  li.get_item() as WindowState;
+                                if (item == null) {
+                                       return;
+                               }
+                               
+                                
+                         
+                               lb.label = item.file.relpath;
                        
                        
                          
@@ -2807,12 +2840,11 @@ public class Xcls_MainWindow : Object
 
                        //listeners
                        this.el.key_released.connect( (keyval, keycode, state) => {
-                               GLib.debug(
-                               
-                                       "key release %d, %d, %d  ?= %d %d" , 
-                                               (int) keyval, (int)  keycode, state,
-                                               (int)Gdk.Key.O, Gdk.ModifierType.CONTROL_MASK
-                                       );
+                               //GLib.debug(
+                               //      "key release %d, %d, %d  ?= %d %d" , 
+                               //              (int) keyval, (int)  keycode, state,
+                               //              (int)Gdk.Key.O, Gdk.ModifierType.CONTROL_MASK
+                               //      );
                                if (keyval == Gdk.Key.Shift_L || keyval == Gdk.Key.Shift_R) {
                                        this.is_shift = 0;
                                }