Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: iamaboringperson on July 19, 2003, 05:56:04 PM

Title: Do i have more logic than my compiler?
Post by: iamaboringperson on July 19, 2003, 05:56:04 PM
...or am i not reading the manual correctly?

ive been mucking around, setting up BOOPSI gadgets
i adjusted a program that worked fine, to make it a bit more efficient, and the new one would cause Intuition to freeze, or the gadgets would take a long time to render, and some would not render at all - i thought my code was fine

then i compared my code to the old code and noticed that basically the only difference between them was that the GA_Previous was pointing to the gadget currently being made using NewObject() !  this should not be, at least i think, strangly it works, and pointing it to the previous gadget only crashes the machine

basically i have an array of gadget pointers:
struct Gadget *mygads[32];

then i basically do this kind of thing:

mygads[0]=(struct Gadget *)NewObject(NULL,"buttongclass",,GA_Previous,mygads[0],TAG_DONE);
mygads[1]=(struct Gadget *)NewObject(NULL,"buttongclass",,GA_Previous,mygads[1],TAG_DONE);

that works! :-o

but [1] should point to
  • IMO!


is the compiler right? or should i be getting some more sleep :-?
Title: Re: Do i have more logic than my compiler?
Post by: Kronos on July 19, 2003, 06:28:23 PM
Hmmm
what happens if you leave out GA_Previous in the 1st call (there is no previous gadget,
so specifing one sounds a bit wrong) and make it

I just checked my own project, and this is what I did:

1. CreateContext() needed if you have GadTools-gadgets. This will create an empty/invisible gadget.

2. CreateGadget() with a pointer the one creted by CreateContext.

3. CreateGadget() with a pointer the one creted by in 2.

and so on.

Finally ad call AddGlist() with the one created in 2.

Should be the same with NewObject instead CreateGadget.
Title: Re: Do i have more logic than my compiler?
Post by: iamaboringperson on July 19, 2003, 06:31:40 PM
Quote
what happens if you leave out GA_Previous in the 1st call
sorry, yeah, i did leave it out in the first call, so the above example is not right
but in the many gadgets that i have created... they all point to themselves and that is the only way the program will work !
Title: Re: Do i have more logic than my compiler?
Post by: Thomas on July 20, 2003, 09:11:48 AM

In such a situation you should:

1. insert some prints between the NewObjects to check the pointers.

2. create and look at the assembler output.

The code with [1] = NewObject([0]) ist right. But your assumption that [1] should point to

Bye,
Thomas