aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Verona2013-03-27 14:01:05 +0100
committerJoakim Verona2013-03-27 14:01:05 +0100
commit17e7bda9299973f29044658aab72dac59efba064 (patch)
treef16476bc81a2dce34c08bf53f998f09b25a5bace
parent10f659bef0c1df7582b26c9f8b38680771077042 (diff)
downloademacs-17e7bda9299973f29044658aab72dac59efba064.tar.gz
emacs-17e7bda9299973f29044658aab72dac59efba064.zip
make xwgir less crash prone when flawed args
-rw-r--r--lisp/xwidget-test.el4
-rw-r--r--src/xwidget.c14
2 files changed, 15 insertions, 3 deletions
diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el
index eabfc0a2817..5e3c309967f 100644
--- a/lisp/xwidget-test.el
+++ b/lisp/xwidget-test.el
@@ -76,7 +76,9 @@
76 (xwidget-insert (point-min) 'xwgir "xwgir" 1000 1000) 76 (xwidget-insert (point-min) 'xwgir "xwgir" 1000 1000)
77 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) 77 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
78 78
79(xwidget-demo "a-xwgir-color-button" 79(xwidget-demo "a-xwgir-color-button"
80 (xwgir-require-namespace "Gtk" "3.0")
81 (put 'ColorButton :xwgir-class '("Gtk" "ColorSelection"))
80 (xwidget-insert (point-min) 'ColorButton "xwgir-color-button" 1000 1000) 82 (xwidget-insert (point-min) 'ColorButton "xwgir-color-button" 1000 1000)
81 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) 83 (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic))
82 84
diff --git a/src/xwidget.c b/src/xwidget.c
index 22993df3a91..caf6aa9aae5 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -901,7 +901,13 @@ xwidget_init_view (struct xwidget *xww,
901#endif 901#endif
902 902
903 903
904 } else { 904 } else //xwgir sanity checks:
905 if(Fget(xww->type, Qcxwgir_class) == Qnil){
906 printf("error, Fget(xww->type, Qcxwgir_class) was nil\n");
907 //we cant just return null here, because drawing will crash later.
908 //currently just display an error component, and stop furher xwgir handling
909 xv->widget = gtk_button_new_with_label ("xwgir failed");
910 } else {
905 //here we have run out of hard coded symbols, we will now attempt to create 911 //here we have run out of hard coded symbols, we will now attempt to create
906 //a widget dynamically 912 //a widget dynamically
907 //TODO 913 //TODO
@@ -909,7 +915,11 @@ xwidget_init_view (struct xwidget *xww,
909 // - support constructor args 915 // - support constructor args
910 // - support signals 916 // - support signals
911 // - check that the argument widget type actually exists 917 // - check that the argument widget type actually exists
912 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)))); 918
919 printf("xwgir symbol %s %s %s:\n",
920 SDATA(SYMBOL_NAME(xww->type)),
921 SDATA(Fcar(Fcdr(Fget(xww->type, Qcxwgir_class)))),
922 SDATA(Fcar(Fget(xww->type, Qcxwgir_class))));
913 //xv->widget = xwgir_create ("Button"); 923 //xv->widget = xwgir_create ("Button");
914 Fcar(Fget(xww->type, Qcxwgir_class)); 924 Fcar(Fget(xww->type, Qcxwgir_class));
915 xv->widget = xwgir_create( SDATA(Fcar(Fcdr(Fget(xww->type, Qcxwgir_class)))), 925 xv->widget = xwgir_create( SDATA(Fcar(Fcdr(Fget(xww->type, Qcxwgir_class)))),