radiobutton.gadget doesn't load/open

This forum is for general developer support questions.

radiobutton.gadget doesn't load/open

Postby javierdlr » Tue Apr 23, 2019 2:32 pm

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 37 times
User avatar
javierdlr
Beta Tester
Beta Tester
 
Posts: 379
Joined: Sun Jun 19, 2011 11:13 pm
Location: Donostia (GUIPUZCOA) - Spain

Re: radiobutton.gadget doesn't load/open

Postby mritter0 » Tue Apr 23, 2019 9:43 pm

gradientslider has the same problem.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 214
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: radiobutton.gadget doesn't load/open

Postby colinw » Wed Apr 24, 2019 1:19 am

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 38 times
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 180
Joined: Mon Aug 15, 2011 10:20 am
Location: Brisbane, QLD. Australia.

Re: radiobutton.gadget doesn't load/open

Postby thomasrapp » Wed Apr 24, 2019 12:48 pm

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
thomasrapp
 
Posts: 279
Joined: Sun Jun 19, 2011 12:22 am

Re: radiobutton.gadget doesn't load/open

Postby trixie » Wed Apr 24, 2019 3:39 pm

@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.
Smoke me a kipper, I'll be back for breakfast!

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
trixie
 
Posts: 395
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: radiobutton.gadget doesn't load/open

Postby broadblues » Wed Apr 24, 2019 8:36 pm

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
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 591
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: radiobutton.gadget doesn't load/open

Postby colinw » Thu Apr 25, 2019 2:28 am

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
colinw
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 180
Joined: Mon Aug 15, 2011 10:20 am
Location: Brisbane, QLD. Australia.

Re: radiobutton.gadget doesn't load/open

Postby javierdlr » Thu Apr 25, 2019 1:33 pm

@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
javierdlr
Beta Tester
Beta Tester
 
Posts: 379
Joined: Sun Jun 19, 2011 11:13 pm
Location: Donostia (GUIPUZCOA) - Spain

Re: radiobutton.gadget doesn't load/open

Postby OldFart » Mon Apr 29, 2019 9:21 am

@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
Sleeping X5000, eagerly awaiting awakening
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 (for sale, willing to split)
RaspBerry Pi 2B, 3B & 4B (4Gb)
User avatar
OldFart
 
Posts: 54
Joined: Tue Jul 12, 2011 3:56 pm
Location: Groningen, Netherlands

Re: radiobutton.gadget doesn't load/open

Postby javierdlr » Tue Apr 30, 2019 1:53 pm

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


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 2 guests