From 17e7bda9299973f29044658aab72dac59efba064 Mon Sep 17 00:00:00 2001 From: Joakim Verona Date: Wed, 27 Mar 2013 14:01:05 +0100 Subject: [PATCH] make xwgir less crash prone when flawed args --- lisp/xwidget-test.el | 4 +++- src/xwidget.c | 14 ++++++++++++-- 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 @@ (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)) 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, #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)))), -- 2.39.2