ag@amix.commodore.com (Keith Gabryelski) (02/09/91)
In lib/Xt/Resources.c:GetResources();line ~934 I see the following code: if (((int) resources->resource_offset) >= 0) { XrmCompileResourceList(resources, num_resources); } It turns out if XtGetApplicationResources() is called as follows: *--------------------------------------* static Boolean Warnings; static XtResource resources[] = { { "warnings", "Warnings", XtRBoolean, sizeof(Boolean), (Cardinal) &Warnings, XtRImmediate, (caddr_t)0, }, }; main() { XtGetApplicationResources(Shell, NULL, resources, XtNumber(resources), NULL, 0); } *--------------------------------------* That is, if `base' (second parameter) is NULL then all resource_offset elements in resources[] must be the address of symbol to modify. On our 68k box the .bss will always be greater than 0x8000000 so the code in GetResources() will always think that such resources have already been compiled and will not bother calling XrmCompileResourceList on the resources array. Has this been discussed before and, if so, has a portable fix been found for this problem? Pax, Keith -- ag@amix.commodore.com Keith Gabryelski ...!cbmvax!amix!ag
cjmchale@cs.tcd.ie (Ciaran McHale) (02/09/91)
In <1012@amix.commodore.com> ag@amix.commodore.com (Keith Gabryelski) writes: >*--------------------------------------* > static Boolean Warnings; > > static XtResource resources[] = > { > { > "warnings", "Warnings", XtRBoolean, sizeof(Boolean), > (Cardinal) &Warnings, XtRImmediate, (caddr_t)0, > }, > }; > > main() > { > XtGetApplicationResources(Shell, NULL, resources, XtNumber(resources), > NULL, 0); > } >*--------------------------------------* > >[Keith recognises that the above code is bugged and asks for a fix] You should have "Warnings" as a member of a structure, rather than a global variable. The second parameter to XtGetApplicationResources() should be a pointer to this structure and in your resources[] array you specify the offset of "Warnings" within the structure. Here's example code to show you what I mean. ----start code---- struct resources_dest_type { unsigned long sea_colour, land_colour; ... /* other resources */ }; resources_dest_type resources_dest; #define offset(member) XtOffsetOf(resources_dest, member) static XtResource resources[] = { {"sea", "Sea", XtRPixel, sizeof(Pixel), offset(sea_colour), XtRString, "SkyBlue"}, {"land", "Land", XtRPixel, sizeof(Pixel), offset(land_colour), XtRString, "MediumAquamarine"}, ... /* other resources */ }; main() { ... XtGetApplicationResources(a_widget, &resources_dest, resources, XtNumber(resources), NULL, 0); ... } ----end code---- I hope that's of some help. Ciaran. -- Ciaran McHale "Verbosity says it all" ____ Department of Computer Science, Trinity College, Dublin 2, Ireland. \ / Telephone: +353-1-772941 ext 1538 FAX: +353-1-772204 \/ Telex: 93782 TCD EI email: cjmchale@cs.tcd.ie
asente@adobe.com (Paul Asente) (02/09/91)
The bug here lies with applications that store the addresses of variables in the resource list and pass NULL as a base. All application resources should be fetched into a structure; the offsets in the resource list should be the offsets of the fields in the structure and the base should be the address of a declared instance of the structure. Actually storing addresses in the resource list is, as you have discovered, horribly unportable. There is no guarantee even that the offset field will be large enough to hold an address. -paul asente asente@adobe.com ...decwrl!adobe!asente
marbru@attc.UUCP (Martin Brunecky) (02/09/91)
In article <10931@adobe.UUCP> asente@adobe.com (Paul Asente) writes: >The bug here lies with applications that store the addresses of variables >in the resource list and pass NULL as a base. All application resources >should be fetched into a structure; the offsets in the resource list should >be ... Mhmm. Everybody here talks about a STRUCTURE. But I want a VARIABLE. Am I wrong using offset of ZERO and a base address equal to the variable address ??? -- =*= Opinions presented here are solely of my own and not those of Auto-trol =*= Martin Brunecky {...}sunpeaks!auto-trol!marbru (303) 252-2499 (sometimes also: marbru@auto-trol.COM ) Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404
asente@adobe.com (Paul Asente) (02/10/91)
In article <1051@attc.UUCP> marbru@auto-trol.UUCP (Martin Brunecky) writes: >In article <10931@adobe.UUCP> asente@adobe.com (Paul Asente) writes: >>The bug here lies with applications that store the addresses of variables >>in the resource list and pass NULL as a base. All application resources >>should be fetched into a structure; the offsets in the resource list should >>be ... > > Mhmm. Everybody here talks about a STRUCTURE. But I want a VARIABLE. > Am I wrong using offset of ZERO and a base address equal to > the variable address ??? Basically, yes. XtFetchApplicationResources only supports fetching resources into a structure. If you have only one variable you can pass the address of the variable as the base and put 0 as the offset in the resource list, but otherwise you have to fetch them into a structure. If you can't live with this you can always fetch them into a structure and then copy the values into the individual variables. -paul asente asente@adobe.com ...decwrl!adobe!asente