Page 1 of 1

radiobutton.gadget doesn't load/open

PostPosted: Tue Apr 23, 2019 2:32 pm
by javierdlr
Hi, using:
...
LAYOUT_AddChild, OBJ(OBJ_RADIO) = IIntuition->NewObject(NULL, "radiobutton.gadget",
...
fails to "auto"open such gadget, all others gadgets do fine (getscreenmode.gadget suffers same problem).

If I add code to create the classpointer, even without using it in source, program works fine.
RadiobuttonBase = IIntuition->OpenClass("gadgets/radiobutton.gadget", 52, &RadiobuttonClass);

System needs to not having radiobutton.gadget already in memory loaded.

Is it a problem in radiobutton (and getscreenmode) includes?

Re: radiobutton.gadget doesn't load/open

PostPosted: Tue Apr 23, 2019 9:43 pm
by mritter0
gradientslider has the same problem.

Re: radiobutton.gadget doesn't load/open

PostPosted: Wed Apr 24, 2019 1:19 am
by colinw
The classes/gadgets are loaded by ramlib.kmod when the subsystem calls Iexec->OpenLibrary(), just like
any library. So if it is a disk based library/gadget, it needs to be in one of the official paths to be found,
the default paths can be overridded by an absolute path, by specifying a path with a colon in it,
eg: "sys:classes/gadgets/radiobutton.gadget", or, "classes:gadgets/radiobutton.gadget", using the dedicated
assignment, however the default paths that ramlib will search in, for libraries/gadgets are as follows (in order);
"LIBS:", "CLASSES:", "CURRDIR:", "CURRDIR:Libs", "CURRDIR:Classes", "PROGDIR:", "PROGDIR:Libs", "PROGDIR:Classes"

So, if you want the default search path to find it, then "CLASSES:" is the default public path, you will need
to specify the subdirectory for the complete path, or it will not work. eg: "gadgets/radiobutton.gadget"
Unless of course it was already loaded in memory by something else previously and hasn't been flushed yet.

Please review the ramlib.doc, it has all this information.

ramlib_doc.lha
Ramlib docs
(916 Bytes) Downloaded 40 times

Re: radiobutton.gadget doesn't load/open

PostPosted: Wed Apr 24, 2019 12:48 pm
by thomasrapp
I don't think that NewObject opens a class if it is not yet loaded and I don't think that NewObject("path/name") will succeed.

You always have to load required resources before you can use them. So OpenClass or OpenLibrary("gadgets/something.gadget") is needed in any case before you can use NewObject, no matter whether you use the class pointer or the public name of the class. Only after the class has been loaded into memory it is known as a public class.

Re: radiobutton.gadget doesn't load/open

PostPosted: Wed Apr 24, 2019 3:39 pm
by trixie
@javierdlr

Are you using the -lauto switch? I think some common BOOPSI classes are loaded and opened by libauto for you automatically. This is why you may be experiencing that certain gadgets don't seem to need opening, while others do.

Re: radiobutton.gadget doesn't load/open

PostPosted: Wed Apr 24, 2019 8:36 pm
by broadblues
Yes indeed, you must open the classlibrary for any gadget you want to use and **must not** rely on some other application having opened first, if all other applications close the library it could get expunged leaving you up a creek without a dispatcher!

For new code by preference use OpenClass() but OpenLibrary will do too.

Sometimes you can 'get away with it' fotr while until your program is the first to be started and suddenly it can't find it's classes on the public list. This happened to me with the UCLogic tablet driver GUI, as I managed to forget to open one of the more common ones, might have been button.gadget! Then when I needed to test from the no startup-sequnce shell it wouldn't work!

Re: radiobutton.gadget doesn't load/open

PostPosted: Thu Apr 25, 2019 2:28 am
by colinw
broadblues wrote:For new code by preference use OpenClass() but OpenLibrary will do too.

Sure, but there is never a need to call OpenLibrary() for a class/gadget yourself.
The first line of code for Intuitions OpenClass() function, IS an internal call to exec OpenLibrary() function,
it just does some extra things afterwards.

So calling OpenClass() requires the same treatment as calling OpenLibrary() for ramlib to find the load file.

Re: radiobutton.gadget doesn't load/open

PostPosted: Thu Apr 25, 2019 1:33 pm
by javierdlr
@trixie No I'm not using -lauto switch. Doesn't matter if I add such switch, such gadget isn't "preloaded".

@all THX I thought NewObject() looked on disk for such files, now I understand it more clear, will use class pointers. Thanks all.

Re: radiobutton.gadget doesn't load/open

PostPosted: Mon Apr 29, 2019 9:21 am
by OldFart
@javierdlr

And for that same matter you have to open "window.class", "layout.gadget" and "button.gadget" (and all other classes & gadgets you want to use) explicitly as well. You only do so for "radiobutton.gadget".

Oldfart

Re: radiobutton.gadget doesn't load/open

PostPosted: Tue Apr 30, 2019 1:53 pm
by javierdlr
OldFart wrote:@javierdlr

And for that same matter you have to open "window.class", "layout.gadget" and "button.gadget" (and all other classes & gadgets you want to use) explicitly as well. You only do so for "radiobutton.gadget".

Oldfart



Yep, you're right. THX