RegisterApplication() & UnregisterApplication()

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:

RegisterApplication() & UnregisterApplication()

Post by javierdlr »

Hi, just added some Printf's to Mixer code and found that when RegisterApplication() & UnregisterApplication() the appID I get next time I execute Mixer it increases +1 the previous appID.
As I UnregisterApplication(), shouldn't next time the same appID be used, as it is "disposed"/freed by UnregisterApplication()?

Piece of code I use in RegisterApplication():
Hidden Text - Click to Show :

Code: Select all

...
 if(WBenchMsg)
  appID = IApplication->RegisterApplication(IDOS->FilePart(mixerfullpath),
                         REGAPP_WBStartup, (ULONG)WBenchMsg,
                         REGAPP_Description, GetString(&li, MSG_COMMODITY),
                         REGAPP_Hidden, !cxPopup,
                         REGAPP_HasIconifyFeature, TRUE,
                         REGAPP_UniqueApplication, TRUE,
                         REGAPP_AppIconInfo, (ULONG)&aii,
                        TAG_DONE);
 else
  appID = IApplication->RegisterApplication(IDOS->FilePart(mixerfullpath),
                         REGAPP_FileName, mixerfullpath,
                         REGAPP_Description, GetString(&li, MSG_COMMODITY),
                         REGAPP_Hidden, !cxPopup,
                         REGAPP_HasIconifyFeature, TRUE,
                         REGAPP_UniqueApplication, TRUE,
                         REGAPP_AppIconInfo, (ULONG)&aii,
                        TAG_DONE);
...
Or maybe is 'REGAPP_UniqueApplication, TRUE' feature?


1)run Mixer for first time:
START create_docky()
appID=0x00000000 'Utilidades:MUSICA/Mixer/Mixer' WBenchMsg=0x57415AC2 cxPopup=1 aii=0x5917CBB8
RegisterApplication(): appID=0x0000000F
AppDocky='Mixer' applibPort=0x5D56D810
END create_docky()
...
2)quit Mixer:
...
UnregisterApplication(): appID=0x0000000F

3)Re-execute Mixer again:
START create_docky()
appID=0x00000000 'Utilidades:MUSICA/Mixer/Mixer' WBenchMsg=0x57415982 cxPopup=1 aii=0x5917CBB8
RegisterApplication(): appID=0x00000010
AppDocky='Mixer' applibPort=0x5D56DB10
END create_docky()
...
User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 525
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Re: RegisterApplication() & UnregisterApplication()

Post by LyleHaze »

From the application autodoc, RegisterApplicationA, Results:

appID - 0 if application registration failed, otherwise an
application ID (== handle) is returned.
An application ID is always unique and is guaranteed to be
*notreused after an application unregistered itself.


;)

The "REGAPP_UniqueApplication" will cause the registration to fail if another instance of the same app is already running.
User avatar
javierdlr
Beta Tester
Beta Tester
Posts: 389
Joined: Sun Jun 19, 2011 10:13 pm
Location: Donostia (GUIPUZCOA) - Spain
Contact:

Re: RegisterApplication() & UnregisterApplication()

Post by javierdlr »

LyleHaze wrote:From the application autodoc, RegisterApplicationA, Results:

appID - 0 if application registration failed, otherwise an
application ID (== handle) is returned.
An application ID is always unique and is guaranteed to be
notreused after an application unregistered itself.
Ooops thx, didn't read that part of autodoc :-)
User avatar
trixie
Posts: 409
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Re: RegisterApplication() & UnregisterApplication()

Post by trixie »

@javierdlr
As I UnregisterApplication(), shouldn't next time the same appID be used, as it is "disposed"/freed by UnregisterApplication()?
No. AppIDs are assigned incrementally with each RegisterApplication(), and are never reused until reboot. This is to prevent applications from possibly talking to "the wrong addressee". Imagine that as part of a routine, "App 1" repeatedly calls SendApplicationMsg() to communicate with "App 2". Now if "App 2" unregistered and its appID got reused, "App 1" would suddenly send messages to an app that doesn't expect them.
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
Post Reply