Parent document is top of "Motif FAQ (Part 4 of 9)"
Previous document is "96) Why does pressing RETURN in a text widget do nothing? This"
Next document is "98) When I add text to a scrolling text widget, how can I get the"
97) Can you reuse the return value from XtParseTranslationTable?
[Last modified: Nov 96]
Answer: The following is a conversation circa 30 Sep 1996 between Kaleb
Keithley (kaleb@x.org) and Tim Behrendsen (tim@a-sis.com, tim@airshields.com>.
The latter suggested this appear in the Motif FAQ.
B> Can the return value from XtParseTranslationTable be saved
TB> off and reused for the lifetime of the application?
KK> Yes.
TB> Ah! The answer. Thank you.
KK>
KK> XtVaSetValues(widget,
KK> XmNtranslations, XtParseTranslationTable(table), NULL);
TB> which implies it's a one-shot deal (otherwise, this would cause
TB> a memory leak).
KK> No, you can always retrieve them with Xt(Va)GetValues.
TB> You can, but if you don't and use the technique to wantonly
TB> create and destroy dialogs, it seems you will get a memory
TB> leak.
KK> That's correct.
TB> In fact, what's scary is this technique is used in the Motif
TB> FAQ list; I knew I saw it somewhere reasonably authoritative
TB> ([approx.] Question 133; code by Dan Heller, O'Reilly and Associates).
TB> He does the following:
TB> XtOverrideTranslations(bboard,
TB> XtParseTranslationTable("<Configure>: resize()"));
TB> This has to be unquestionably broken code, if the translation
TB> tables are never freed or never reused. Obviously, I can't
TB> extract out the table from overridden translations.
KK> You can't extract the original translations, that's correct.
TB> Come to think of it; how is this handled when translations are
TB> parsed in resource files? If I have lots of translation
TB> overrides, do they simply burn up space that can't be reused?
TB> Does it get burned up over and over as I create widgets that
TB> use those translation resources?
KK> Yup and yup.
Parent document is top of "Motif FAQ (Part 4 of 9)"
Previous document is "96) Why does pressing RETURN in a text widget do nothing? This"
Next document is "98) When I add text to a scrolling text widget, how can I get the"