Re: XForms: Segmentation Faults with C++

Alberto BARSELLA (ishark@lsh01.univ-lille1.fr)
Thu, 25 Feb 1999 16:48:36 +0000 (/etc/localtime)

# To subscribers of the xforms list from Alberto BARSELLA <ishark@lsh01.univ-lille1.fr> :

Hi,

> # To subscribers of the xforms list from Thomas Thiel <wolfchild@home.ivm.de> :
>
> But I am interested in the workarounds you mentioned ! Would you please
> show me one or two of these ?

I think they were discussed on the list, so you may want to check the
archive for some explicit code. The ones I can think of (i.e. I used or
decided not to use) are:

1) don't use member functions :)
2) store somewhere a "currently active object", all the callbacks are
invoked on that object. Sometimes it's ok, sometimes it isn't.
Having a single instance is a good case where it's ok.
3) xforms objects contain a void pointer which can be used by the
application to store any kind of information (called vdata, if I
remember correctly). You can then (in your constructor) store the
value of this into any FL_OBJECT which has a callback: for the callback
itself you'll use a non-member function which extracts the object
address from the FL_OBJECT and invokes the method.
4) (a messy one) search for object: a FL_OBJECT contains a pointer to the
form it is part of, an object like yours know which form is using, by
crossing the information the callback can understand whose method it
should invoke.

If you only have one instance and are using a class just in case one day
you may have a second instance go for method #2 (which will, in turn, be
followed by method #4 - which is a hack -: you already have all the stuff
and you want to add one more instance without playing with how the objects
works).

Method #3 is the more powerful and general one and if you're about to
write your program you should use it (even better would be to put in the
FL_OBJECT a pointer to a structure which contains anything you may need.
The object address today, but something else in the future).

Bye,
Alberto

--
Alberto BARSELLA
PGP fingerprint = 13 3F 22 D2 0B 0A D3 25  F1 89 FE B5 82 AD 75 2A
** Beliefs are dangerous. Beliefs allow the mind to stop functioning.
A non-functioning mind is clinically dead.  Believe in nothing... **

_________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuhs.mil or see http://bob.usuhs.mil/mailserv/xforms.html XForms Home Page: http://bragg.phys.uwm.edu/xforms List Archive: http://bob.usuhs.mil/mailserv/list-archives/