]> code.delx.au - gnu-emacs/commitdiff
make xwgir less crash prone when flawed args
authorJoakim Verona <joakim@verona.se>
Wed, 27 Mar 2013 13:01:05 +0000 (14:01 +0100)
committerJoakim Verona <joakim@verona.se>
Wed, 27 Mar 2013 13:01:05 +0000 (14:01 +0100)
lisp/xwidget-test.el
src/xwidget.c

index eabfc0a281737e7797716de948181efd110c2d43..5e3c309967fc7f2e3a506b44844ecdc4c20f01be 100644 (file)
@@ -76,7 +76,9 @@
               (xwidget-insert (point-min)  'xwgir "xwgir" 1000  1000)
               (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
 
-(xwidget-demo "a-xwgir-color-button" 
+(xwidget-demo "a-xwgir-color-button"
+               (xwgir-require-namespace "Gtk" "3.0")
+               (put 'ColorButton :xwgir-class '("Gtk" "ColorSelection"))
               (xwidget-insert (point-min)  'ColorButton "xwgir-color-button" 1000  1000)
               (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
 
index 22993df3a91041f521f5216106813ce82d29d177..caf6aa9aae54ecd0b2636a3fa708ccf5b77f05fe 100644 (file)
@@ -901,7 +901,13 @@ xwidget_init_view (struct xwidget *xww,
 #endif
 
 
-  } else {
+  } else     //xwgir sanity checks:
+    if(Fget(xww->type, Qcxwgir_class) == Qnil){
+      printf("error, Fget(xww->type, Qcxwgir_class) was nil\n");
+      //we cant just return null here, because drawing will crash later.
+      //currently just display an error component, and stop furher xwgir handling
+      xv->widget = gtk_button_new_with_label ("xwgir failed");
+    } else {
     //here we have run out of hard coded symbols, we will now attempt to create
     //a widget dynamically
     //TODO
@@ -909,7 +915,11 @@ xwidget_init_view (struct xwidget *xww,
     // - support constructor args
     // - support signals
     // - check that the argument widget type actually exists
-    printf("xwgir symbol %s %s %s:\n",SDATA(SYMBOL_NAME(xww->type)),     SDATA(Fcar(Fcdr(Fget(xww->type, Qcxwgir_class)))), SDATA(Fcar(Fget(xww->type, Qcxwgir_class))));
+
+    printf("xwgir symbol %s %s %s:\n",
+           SDATA(SYMBOL_NAME(xww->type)),
+           SDATA(Fcar(Fcdr(Fget(xww->type, Qcxwgir_class)))),
+           SDATA(Fcar(Fget(xww->type, Qcxwgir_class))));
     //xv->widget = xwgir_create ("Button");
     Fcar(Fget(xww->type, Qcxwgir_class));
     xv->widget = xwgir_create(    SDATA(Fcar(Fcdr(Fget(xww->type, Qcxwgir_class)))),