claire@Solbourne.COM (Claire Campbell) (11/15/89)
I have a question regarding initialization of Xt. I have seen the comment "The semantics of calling XtToolkitInitialize more than once are undefined", and am wondering why this is. I have a library which may use Xt widgets as input devices. An application which uses this library may or may not also be using Xt widgets. My problem comes in the case that both the application and the library use Xt widgets (i.e. they both make calls to XtAppInitialize). Is there a way to find out if the toolkit has already been initialized? (In that case I would have to have my own XtAppInitialize() which would be the same minus the call to XtToolkitInitialize, I guess?) In looking at the code, I found that most of the routines that XtToolkitInitialize calls maintain a static 'initialized' variable so that repeated calls have no affect. However, two routines, XrmInitialize() and _XtEventInitialize() do not. In my case, it appears that repeatedly calling _XtEventInitialize() is the problem. I have gotten my application and library to work together successfully by adding the static 'initialized' check to XtToolkitInitialize itself. However, I am not familiar enough with Xt to know if this is safe, legal, smart, etc. Another solution would be for my application to 'let the library know' if it will be doing the toolkit initialization, but if there's a built in way of finding out, I'd like to know about it. Thanks for any help! Claire Claire Campbell Solbourne Computer, Inc. claire@solbourne.com (303) 772-3400 ...{uunet,boulder,sun}!stan!claire
swick@ATHENA.MIT.EDU (Ralph R. Swick) (11/15/89)
> I have seen the > comment "The semantics of calling XtToolkitInitialize more than once > are undefined", and am wondering why this is. The comment exists to warn application developers that the effect of calling this routine more than once is dependent upon the particular implementation of Xt. Therefore, any application which relies on a particular behaviour is non-portable. > Is there a way to find out if the toolkit has already been initialized? Not directly, though there are several areas where a side-effect is readily observable. For example, if any composite widget has been created (including a top-level shell) then the resource list returned by XtGetResourceList(compositeWidgetClass) will contain the Core resources, otherwise it will only contain the Composite resources. > Another solution would be for my application to 'let the library know' > if it will be doing the toolkit initialization ... or provide a MyLibraryInitialize procedure which does the Xt initialization. If your library expects to share an application context with the application then you'll have to communicate this information anyway. If you library is creating a separate application context then to be portable you'll have to provide some way for the application to tell you whether or not to initialize Xt.