radiobutton.gadget doesn't load/open

This forum is for general developer support questions.
Post Reply
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

radiobutton.gadget doesn't load/open

Post 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?
Attachments
radiobutton.zip
(2.16 KiB) Downloaded 272 times
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: radiobutton.gadget doesn't load/open

Post by mritter0 »

gradientslider has the same problem.
Workbench Explorer - A better way to browse drawers
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 207
Joined: Mon Aug 15, 2011 9:20 am
Location: Brisbane, QLD. Australia.

Re: radiobutton.gadget doesn't load/open

Post 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 286 times
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

Re: radiobutton.gadget doesn't load/open

Post 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.
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: radiobutton.gadget doesn't load/open

Post 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.
The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: radiobutton.gadget doesn't load/open

Post 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!
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 207
Joined: Mon Aug 15, 2011 9:20 am
Location: Brisbane, QLD. Australia.

Re: radiobutton.gadget doesn't load/open

Post 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.
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: radiobutton.gadget doesn't load/open

Post 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.
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: radiobutton.gadget doesn't load/open

Post 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
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: radiobutton.gadget doesn't load/open

Post 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
Post Reply