calling a library which creates widgets multiple times a few days ago i posted a question about trying to call a function which set up an x app multiple times it was pointed out that xtappinitialize should never be called more than once this helped however i am still having some problems below is a new little test program that more closely models my real program in the actual program i am writing a library callable from any other program this means that the first time the lib function is called it must initialize things and after that it should just use the old stuff still around because of static variables in the demo below main represents the main program calling my library and doit represents the interface to the library function include x xlib h include xm xm h include xm pushb h include stdio h include stdlib h void bla xtappcontext app widget top widget topone top in real prog these are member vars xtappcontext theapp app of a class int junk display dis xtopendisplay theapp null null null null junk null widget box xtvacreatemanagedwidget blaaa xmpushbuttonwidgetclass topone xmnheight xmnwidth null xtrealizewidget topone for int i i i real prog returns when exit button clicked xevent event xtappnextevent theapp event xtdispatchevent event xtdestroywidget box xtclosedisplay dis setitup should be called once only void setitup xtappcontext app widget top int junk top xtappinitialize app test null junk null null null doit some library function callable from the outside void doit static xtappcontext app use these every time called static widget top static int setup if setup setitup app top setup bla app top main program which links to my library main for int i i i doit printf sleeping n widget still on screen at this point sleep the problem is that the widget does not go away until the new one is created it is still on the screen unusuable during the sleep in the main prog despite the xtdestroywidget call anyone see something i m missing thanks very much please respond via email david rex wood davewood cs colorado edu university of colorado at boulder
