Fix #7383 - reduce complier warnings
authorAlan Knowles <alan@roojs.com>
Sat, 3 Sep 2022 11:04:04 +0000 (19:04 +0800)
committerAlan Knowles <alan@roojs.com>
Sat, 3 Sep 2022 11:04:04 +0000 (19:04 +0800)
src/Application.vala
src/Builder4/EditProject.bjs
src/Builder4/EditProject.vala
src/Builder4/Editor.bjs
src/Builder4/Editor.vala
src/Builder4/GtkView.bjs
src/Builder4/GtkView.vala
src/Builder4/PopoverAddObject.bjs
src/Builder4/PopoverAddObject.vala
src/JsRender/NodeToVala.vala
src/Makefile.am

index dc46873..2772a56 100644 (file)
                                 return new AppSettings();
                        }
                        string data; 
-                       FileUtils.get_contents(setting_file, out data);
-                       return Json.gobject_from_data (typeof (AppSettings), data) as AppSettings;
+                       try { 
+                               FileUtils.get_contents(setting_file, out data);
+                               return Json.gobject_from_data (typeof (AppSettings), data) as AppSettings;
+                       } catch (Error e) {
+                       }
+                       return new AppSettings();
                }
                public void save()
                {
                        var dirname = GLib.Environment.get_home_dir() + "/.Builder";
                        var setting_file = dirname + "/builder.settings";
                        string data = Json.gobject_to_data (this, null);
-                       print("saving application settings\n");
-                       FileUtils.set_contents(setting_file,   data);
+                       GLib.debug("saving application settings\n");
+                       try {
+                               FileUtils.set_contents(setting_file,   data);
+                       } catch (Error e) {
+                               print("Error saving app settings");
+                       }
                }
 
                
                public BuilderApplication (  string[] args)
                {
                        
-                       
-                       _self = FileUtils.read_link("/proc/self/exe");
+                       try {
+                               _self = FileUtils.read_link("/proc/self/exe");
+                       } catch (Error e) {
+                               // this should nto happen!!?
+                               GLib.error("could not read /proc/self/exe");
+                       }
                        GLib.debug("SELF = %s", _self);
                        
                        Object(
                
                        if (!FileUtils.test(dirname,FileTest.IS_DIR)) {
                                var dir = File.new_for_path(dirname);
-                               dir.make_directory();    
+                               try {
+                                       dir.make_directory();   
+                               } catch (Error e) {
+                                       GLib.error("Failed to make directory %s", dirname);
+                               } 
                        }
                        if (!FileUtils.test(dirname + "/resources",FileTest.IS_DIR)) {
                                var dir = File.new_for_path(dirname + "/resources");
-                               dir.make_directory();    
+                               try {
+                                       dir.make_directory();   
+                               } catch (Error e) {
+                                       GLib.error("Failed to make directory %s", dirname + "/resources");
+                               } 
                        }
 
                
                                GLib.error("missing project, use --project to select which project");
                        }
                        print("Checking files\n");
-                       var ar = cur_project.sortedFiles();
-                       foreach(var file in ar) {
-                               string oldstr;
+                       try { 
+                               var ar = cur_project.sortedFiles();
+                               foreach(var file in ar) {
+                                       string oldstr;
 
-                               file.loadItems();
-                               GLib.FileUtils.get_contents(file.path, out oldstr);                             
-                               var outstr = file.toJsonString();
-                               if (outstr != oldstr) { 
+                                       file.loadItems();
+                                       GLib.FileUtils.get_contents(file.path, out oldstr);                             
+                                       var outstr = file.toJsonString();
+                                       if (outstr != oldstr) { 
+                                               
+                                               GLib.FileUtils.set_contents("/tmp/" + file.name ,   outstr);
+                                               print("meld  %s /tmp/%s\n", file.path,  file.name);
+                                               //GLib.Process.exit(Posix.EXIT_SUCCESS);                
+                                       }
+                                       print("# Files match %s\n", file.name);
                                        
-                                       GLib.FileUtils.set_contents("/tmp/" + file.name ,   outstr);
-                                       print("meld  %s /tmp/%s\n", file.path,  file.name);
-                                       //GLib.Process.exit(Posix.EXIT_SUCCESS);                
                                }
-                               print("# Files match %s\n", file.name);
-                               
+                       } catch (FileError e) {
+                               GLib.debug("Got error %s", e.message);
+                       } catch (Error e) {
+                               GLib.debug("Got error %s", e.message);
                        }
-                       
+                               
                        print("All files pass");
                        GLib.Process.exit(Posix.EXIT_SUCCESS);
                }
                        }
                        
                        if (BuilderApplication.opt_bjs_compile == "all") {
-                               var ar = cur_project.sortedFiles();
-                               foreach(var file in ar) {
-                                       string oldstr;
-
-                                       file.loadItems();
-                                       var oldfn = file.targetName();
-                                       GLib.FileUtils.get_contents(oldfn, out oldstr);
-                                                                       
-                                       var outstr = file.toSourceCode();
-                                       if (outstr != oldstr) { 
-                                               
-                                               GLib.FileUtils.set_contents("/tmp/" + file.name   + ".out",   outstr);
-                                               print("meld   %s /tmp/%s\n", oldfn,  file.name + ".out");
-                                               //GLib.Process.exit(Posix.EXIT_SUCCESS);                
-                                       }
-                                       print("# Files match %s\n", file.name);
+                               try { 
+                                       var ar = cur_project.sortedFiles();
                                        
+                                       foreach(var file in ar) {
+                                               string oldstr;
+
+                                               file.loadItems();
+                                               var oldfn = file.targetName();
+                                               GLib.FileUtils.get_contents(oldfn, out oldstr);
+                                                                               
+                                               var outstr = file.toSourceCode();
+                                               if (outstr != oldstr) { 
+                                                       
+                                                       GLib.FileUtils.set_contents("/tmp/" + file.name   + ".out",   outstr);
+                                                       print("meld   %s /tmp/%s\n", oldfn,  file.name + ".out");
+                                                       //GLib.Process.exit(Posix.EXIT_SUCCESS);                
+                                               }
+                                               print("# Files match %s\n", file.name);
+                                       }               
+                               } catch (FileError e) {
+                                       GLib.debug("Got error %s", e.message);
+                               } catch (Error e) {
+                                       GLib.debug("got error %s", e.message);
                                }
+                               
                                GLib.Process.exit(Posix.EXIT_SUCCESS);
                        
                        }
                        
                                GLib.error("missing file %s in project %s", BuilderApplication.opt_bjs_compile, cur_project.name);
                        }
-                       file.loadItems();
-                                               
+                       try {
+                               file.loadItems();
+                       } catch(Error e) {
+                               GLib.debug("Load items failed");
+                       }
+                                       
                        if (BuilderApplication.opt_bjs_compile_glade) {
                                var str = file.toGlade();
                                print("%s", str);
@@ -401,7 +438,7 @@ flutter-project  - create a flutter project in /tmp/test-flutter
                                        break;
                                case "flutter-project":
                                Project.Project.loadAll();
-                                       var p =   Project.Project.factory("Flutter", "/tmp/test-flutter");
+                                       //var p =   Project.Project.factory("Flutter", "/tmp/test-flutter");
                                        /*var pa = p.palete as Palete.Flutter;
                                        pa.dumpusage();
                                         var ar = pa.getChildList("material.Scaffold");
index baea2b0..0e6887b 100644 (file)
     " ",
     "    var fn = _this.dir.el.get_filename();",
     "    print(\"add %s\\n\" , fn);",
-    "    ",
-    "    var project = Project.Project.factory(_this.xtype.getValue(), fn);",
-    "    project.save();",
-    "    Project.projects.set(project.name,project);",
-    "    ",
+    "    try {",
+    "\t\tvar project = Project.Project.factory(_this.xtype.getValue(), fn);",
+    "\t\tproject.save();",
+    "\t\tProject.projects.set(project.name,project);",
+    "\t\treturn project;",
+    "\t} catch (Error e) {",
+    "\t\tGLib.debug(\"got error? %s\" , e.message);",
+    "\t}",
     "    //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);",
+    "    return null;",
     "    ",
-    "    return project;",
     "",
     "    ",
     "    //this.success = c.success;",
index e666e67..6883d98 100644 (file)
@@ -37,7 +37,7 @@ public class EditProject : Object
         this.el.modal = true;
         var child_0 = new Xcls_Box2( _this );
         child_0.ref();
-        this.el.get_content_area().add (  child_0.el  );
+        this.el.get_content_area().add( child_0.el );
         var child_1 = new Xcls_Button9( _this );
         child_1.ref();
         this.el.add_action_widget (  child_1.el , 1 );
@@ -97,14 +97,17 @@ public class EditProject : Object
      
         var fn = _this.dir.el.get_filename();
         print("add %s\n" , fn);
-        
-        var project = Project.Project.factory(_this.xtype.getValue(), fn);
-        project.save();
-        Project.projects.set(project.name,project);
-        
+        try {
+               var project = Project.Project.factory(_this.xtype.getValue(), fn);
+               project.save();
+               Project.projects.set(project.name,project);
+               return project;
+       } catch (Error e) {
+               GLib.debug("got error? %s" , e.message);
+       }
         //var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);
+        return null;
         
-        return project;
     
         
         //this.success = c.success;
@@ -271,7 +274,7 @@ public class EditProject : Object
         {
             _this = _owner;
             _this.model = this;
-            this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
+            this.el = new Gtk.ListStore.newv(  { typeof(string),typeof(string) }  );
 
             // my vars (dec)
 
index 07cc131..c520ded 100644 (file)
          "    ",
          "  ",
          " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
-         "\t\tvar res = _this.search(this.el.text);",
+         "\t\t//var res =",
+         "\t\t _this.search(this.el.text);",
          "\t\t _this.search_results.updateResults();",
          "",
          "\t\tGLib.Timeout.add_seconds(2,() => {",
index 8bf9cbd..6c8a385 100644 (file)
@@ -965,7 +965,8 @@ public class Editor : Object
                 
               
                if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {
-                       var res = _this.search(this.el.text);
+                       //var res =
+                        _this.search(this.el.text);
                         _this.search_results.updateResults();
             
                        GLib.Timeout.add_seconds(2,() => {
index fe4fb3d..2aacf52 100644 (file)
              "    ",
              "  ",
              " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
-             "\t\tvar res = _this.search(this.el.text);",
+             "\t\t_this.search(this.el.text);",
              "\t\t _this.search_results.updateResults();",
              "",
              "\t\tGLib.Timeout.add_seconds(2,() => {",
     "    var  win = this.el.get_parent_window();",
     "    var width = win.get_width();",
     "    var height = win.get_height();",
-    "    try {",
+    "    //try {",
     "         Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?",
     "         this.file.writeIcon(screenshot);",
-    "    } catch (Error e) {",
+    "    //} catch (Error e) {",
     "        ",
-    "    }",
+    "    //}",
     "",
     "   ",
     "    return;",
     "\t\treturn;",
     "\t}",
     "\tthis.notebook.el.page = 1;",
-    "\tGtk.TextIter beg, st,en, stl;",
+    "\tGtk.TextIter beg, st,en;",
     "\t",
     "\tvar buf = this.sourceview.el.get_buffer();",
     "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
index af57595..198deb6 100644 (file)
@@ -198,7 +198,7 @@ public class Xcls_GtkView : Object
                return;
        }
        this.notebook.el.page = 1;
-       Gtk.TextIter beg, st,en, stl;
+       Gtk.TextIter beg, st,en;
        
        var buf = this.sourceview.el.get_buffer();
        buf.get_iter_at_offset(out beg, this.last_search_end);
@@ -294,12 +294,12 @@ public class Xcls_GtkView : Object
         var  win = this.el.get_parent_window();
         var width = win.get_width();
         var height = win.get_height();
-        try {
+        //try {
              Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, height); // this.el.position?
              this.file.writeIcon(screenshot);
-        } catch (Error e) {
+        //} catch (Error e) {
             
-        }
+        //}
     
        
         return;
@@ -1013,7 +1013,7 @@ public class Xcls_GtkView : Object
                 
               
                if (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {
-                       var res = _this.search(this.el.text);
+                       _this.search(this.el.text);
                         _this.search_results.updateResults();
             
                        GLib.Timeout.add_seconds(2,() => {
index 7e6a871..cce6c32 100644 (file)
      "xtype" : "ScrolledWindow"
     }
    ],
-   "listeners" : {
-    "hide" : [
-     "( ) => {",
-     "",
-     "}",
-     ""
-    ]
-   },
    "xtype" : "Popover",
    "| void clear" : [
     "() {",
     "",
     "    ",
     "   ",
-    " ",
     "",
     "    var tr = pal.getChildList(cls);",
     "    this.model.el.clear();",
     "",
     "    Gtk.TreeIter citer;",
     "    var ic = Gtk.IconTheme.get_default();",
-    "\tvar pixdef = ic.load_icon(\"emblem-new\", 16,0);",
+    "    Gdk.Pixbuf pixdef = null;",
+    "    try {",
+    "\t\tpixdef = ic.load_icon(\"emblem-new\", 16,0);",
+    "\t} catch (Error e) {",
+    "\t}",
     "",
     "    for(var i =0 ; i < tr.length; i++) {",
     "         this.model.el.append(out citer);   ",
     "    ",
     "    ",
     "    ",
-    "    ",
-    "    ",
     "    // set size up...",
     "    ",
     "    this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);",
index 1ef9858..f45560c 100644 (file)
@@ -41,11 +41,6 @@ public class Xcls_PopoverAddObject : Object
         var child_0 = new Xcls_ScrolledWindow2( _this );
         child_0.ref();
         this.el.add (  child_0.el  );
-
-        //listeners
-        this.el.hide.connect( ( ) => {
-        
-        });
     }
 
     // user defined functions
@@ -53,7 +48,6 @@ public class Xcls_PopoverAddObject : Object
     
         
        
-     
     
         var tr = pal.getChildList(cls);
         this.model.el.clear();
@@ -61,7 +55,11 @@ public class Xcls_PopoverAddObject : Object
     
         Gtk.TreeIter citer;
         var ic = Gtk.IconTheme.get_default();
-       var pixdef = ic.load_icon("emblem-new", 16,0);
+        Gdk.Pixbuf pixdef = null;
+        try {
+               pixdef = ic.load_icon("emblem-new", 16,0);
+       } catch (Error e) {
+       }
     
         for(var i =0 ; i < tr.length; i++) {
              this.model.el.append(out citer);   
@@ -94,8 +92,6 @@ public class Xcls_PopoverAddObject : Object
         
         
         
-        
-        
         // set size up...
         
         this.model.el.set_sort_column_id(0,Gtk.SortType.ASCENDING);
index 8e3d55b..70367ec 100644 (file)
@@ -884,7 +884,7 @@ public class JsRender.NodeToVala : Object {
                                var named = child.has("stack_name") ?  child.get_prop("stack_name").val.escape() : "";
                                var title = child.has("stack_title") ?  child.get_prop("stack_title").val.escape()  : "";
                                if (title.length > 0) {
-                                       this.addLine(this.ipad + "this.el.add_titled(  child_%d.el, \"%\", \"%s\" );".printf(i,named,title));   
+                                       this.addLine(this.ipad + "this.el.add_titled(  child_%d.el, \"%s\", \"%s\" );".printf(i,named,title));  
                                } else {
                                        this.addLine(this.ipad + "this.el.add_named(  child_%d.el, \"%s\" );".printf(i,named));
                                }
index 6fa845e..b5ee5bb 100644 (file)
@@ -138,8 +138,11 @@ endif
  
 # - not sure if needed....  
 
-AM_CPPFLAGS =  $(ROOBUILDER_CFLAGS) $(WEBKIT_CFLAGS) $(GDA_CFLAGS) $(LIBVALA_CFLAGS) $(JAVASCRIPTCOREGTK_CFLAGS) $(VTE_CFLAGS)
-
+AM_CPPFLAGS =  $(ROOBUILDER_CFLAGS) $(WEBKIT_CFLAGS) $(GDA_CFLAGS) $(LIBVALA_CFLAGS) $(JAVASCRIPTCOREGTK_CFLAGS) $(VTE_CFLAGS) \
+    -Wno-incompatible-pointer-types \
+    -Wno-discarded-qualifiers \
+    -Wno-deprecated-declarations \
+    -Wno-pointer-to-int-cast
 
 bin_PROGRAMS = roobuilder