[Motiftools-xmt-cvs] CVS: xmt/Xmt NameToWidget.c,1.3,1.4
Brought to you by:
motiftools
From: Grant M. <grm...@us...> - 2003-10-27 20:29:06
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv9547 Modified Files: NameToWidget.c Log Message: Improved - and failsafe - detection of uninitialized widget Index: NameToWidget.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/NameToWidget.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** NameToWidget.c 19 Sep 2001 02:57:18 -0000 1.3 --- NameToWidget.c 27 Oct 2003 20:22:05 -0000 1.4 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.4 2003/10/27 20:22:05 grmcdorman + * Improved - and failsafe - detection of uninitialized widget + * * Revision 1.3 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 94,98 **** static XrmQuark selfq = NULLQUARK; static XrmQuark questionq = NULLQUARK; ! #if NeedFunctionPrototypes static Widget GetParent(Widget w) --- 97,142 ---- static XrmQuark selfq = NULLQUARK; static XrmQuark questionq = NULLQUARK; ! ! /* Detect if a widget is not initialized. This will be the case when: ! * 1) this widget is a Shell, and does not appear in the parent's ! * list of popups. ! * or 2) this widget is not a Shell, and does not appear in the parent's ! * list of children. ! */ ! #if NeedFunctionPrototypes ! static int WidgetInitialized(Widget w) ! #else ! static int WidgetInitialized(w) ! Widget w; ! #endif ! { ! int initialized = 1; ! int i; ! ! if (w->core.parent != NULL) { ! Widget container = w->core.parent; ! int initialized = 0; ! if (XtIsShell(w)) { ! /* shell; look in parent's popup list */ ! for (i = 0; i < container->core.num_popups; i++) { ! if (container->core.popup_list[i] == w) { ! initialized = 1; ! break; ! } ! } ! } else if XtIsComposite(container) { ! /* ordinary widget */ ! CompositeWidget composite = (CompositeWidget) container; ! for (i = 0; i < composite->composite.num_children; i++) { ! if (composite->composite.children[i] == w) { ! initialized = 1; ! break; ! } ! } ! } ! } ! return initialized; ! } ! #if NeedFunctionPrototypes static Widget GetParent(Widget w) *************** *** 149,152 **** --- 193,199 ---- int i; + /* An uninitialized widget can't have any children or popups. */ + if (!WidgetInitialized(w)) return NULL; + /* * Check the names of all normal children. *************** *** 167,172 **** /* popup children names */ ! /* try to handle unintialized 'num_popups' */ ! if (w->core.num_popups < 50 && w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (w->core.popup_list[i]->core.xrm_name == q) --- 214,218 ---- /* popup children names */ ! if (w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (w->core.popup_list[i]->core.xrm_name == q) *************** *** 183,187 **** /* popup children classes */ /* try to handle unintialized 'num_popups' */ ! if (w->core.num_popups < 50 && w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (XtClass(w->core.popup_list[i])->core_class.xrm_class == q) --- 229,233 ---- /* popup children classes */ /* try to handle unintialized 'num_popups' */ ! if (w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (XtClass(w->core.popup_list[i])->core_class.xrm_class == q) *************** *** 395,399 **** } w2 = (*matchproc)(names, bindings, num_quarks, root->core.popup_list, ! root->core.num_popups < 50 && root->core.num_popups > 0 ? root->core.num_popups : 0, in_depth, &d2, found_depth); *out_depth = (d1 < d2 ? d1 : d2); --- 441,445 ---- } w2 = (*matchproc)(names, bindings, num_quarks, root->core.popup_list, ! WidgetInitialized(root) && root->core.num_popups > 0 ? root->core.num_popups : 0, in_depth, &d2, found_depth); *out_depth = (d1 < d2 ? d1 : d2); |