Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.windows.x Frequently Asked Questions (FAQ) 6/7
Section - 147) Why can't I get data back in my callback procedure?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Sex offenders ]


Top Document: comp.windows.x Frequently Asked Questions (FAQ) 6/7
Previous Document: 140)+ How do I check whether an Xt widget is still valid?
Next Document: 148) Why isn't there an XtReparentWidget call like XReparentWindow?
See reader questions & answers on this topic! - Help others by sharing your knowledge

You may hit a situation in which using XtAddCallback(button, XtNcallback,
CBproc, pointer) doesn't work to retrieve "pointer".

Almost certainly, what you are seeing is the effect of using local variables
after they are no longer in existence. In the above line of code, "pointer"
is probably a local variable declared within the block of code making the call
to XtAddCallback; it is valid only within the scope of the callback, and is
not valid by the time the callback CBproc gets called. Within CBproc, the
client_data argument is pointing to somewhere on the stack -- whereever
pointer was when it was used.  

Short of using global or static data, the best solution is to allocate a
pointer to the data you need and free it in the callback routine.

Short values such as integers can be passed directly without resorting to
this code; nor do you need to do allocations for other data which will be in
existence when the callback is called, such as other widgets which haven't
been destroyed.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.windows.x Frequently Asked Questions (FAQ) 6/7
Previous Document: 140)+ How do I check whether an Xt widget is still valid?
Next Document: 148) Why isn't there an XtReparentWidget call like XReparentWindow?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
faq%craft@uunet.uu.net (X FAQ maintenance address)





Last Update March 27 2014 @ 02:12 PM