Notification when Amigaguide closed?

This forum is for general developer support questions.

Notification when Amigaguide closed?

Postby chris » Mon Feb 10, 2014 9:53 pm

Is there any way to find out when my AmigaGuide document (opened with OpenAmigaGuideASync) has been closed by the user?

I can see some relevant-looking things in libraries/amigaguide.h:
Code: Select all
#define ShutdownMsgID    (APSH_TOOL_ID+4L)  /* Shutdown message */
#define ShutdownToolID   (APSH_TOOL_ID+12L) /* Shutdown tool */

/* Callback function ID's */
#define HTH_OPEN  0
#define HTH_CLOSE 1


I'm waiting and processing AmigaGuide messages, but only getting ToolCmdReplyID, not any of the Shutdown messages.
The callbacks I can find no reference to in the documentation - I'm quite happy to add a callback for when the document is closed (in fact, it's preferable), but can't see how to do this.
chris
 
Posts: 551
Joined: Sat Jun 18, 2011 12:05 pm

Re: Notification when Amigaguide closed?

Postby tonyw » Tue Feb 11, 2014 12:05 am

A quick look doesn't make me any the wiser. The doc says that OpenAmigaguideAsync() spawns an instance of OpenAmigaguide(), as you already know.

I can see no reference in the code to sending any sort of message on exit. Those commands you quoted (ShutdownMsgID and ShutdownToolID) are commands to the amigaguide process, not return values.

I don't profess to be an expert, but I think you can only use the non-sync version and wait for it to return on exit. That may require that you spawn your own Process to call OpenAmigaguide(), wait for it and exit with a Death Message when it returns.
cheers
tony
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 1314
Joined: Wed Mar 09, 2011 2:36 pm
Location: Sydney, Australia

Re: Notification when Amigaguide closed?

Postby trixie » Tue Feb 11, 2014 12:48 am

@chris

Out of curiosity - why do you need to know if the document was closed?
Smoke me a kipper, I'll be back for breakfast!

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon R5 230 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 373
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Notification when Amigaguide closed?

Postby chris » Tue Feb 11, 2014 1:11 am

trixie wrote:@chris

Out of curiosity - why do you need to know if the document was closed?


To tidy up, of course! You can't free all the resources until the AmigaGuide process has closed. It seems very strange that you can't tell when the user has finished with it. Specifically, it is allocating signals that I'm a bit fidgety about, as I'm running out.

@tonyw
Is this a feature request then? It shouldn't be very difficult to make the process that spawns OpenAmigaGuide send a message to the message port after it returns.
chris
 
Posts: 551
Joined: Sat Jun 18, 2011 12:05 pm

Re: Notification when Amigaguide closed?

Postby trixie » Tue Feb 11, 2014 2:09 am

@chris

To tidy up, of course! You can't free all the resources until the AmigaGuide process has closed.

I'm using asynchronous AmigaGuide help in my software (I did send you my amigaguide.class code, didn't I?), and I never really needed the system to tell me when the database was closed. This is how it works basically:

- OM_NEW calls OpenAmigaGuideAsync() and allocates the database resources (the document window doesn't get opened in async mode).
- When the user requests help, the opening method (AGM_OPEN) is called. The method calls SendAmigaGuideCmd() to actually display the document. Should the document window be already opened, the command brings it to front (i.e. just one asynchronously-opened instance of the help file is allowed).
- The help file stays open as long as the user wishes.
- When you quit your program, you call OM_DISPOSE upon your help file object, which first calls AGM_CLOSE to close the document window (if it is still opened) and deallocates all resources.

So it's one help file, one allocation, one deallocation. What other tidying-up do you need?
Smoke me a kipper, I'll be back for breakfast!

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon R5 230 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 373
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Notification when Amigaguide closed?

Postby chris » Tue Feb 11, 2014 2:20 am

Yes, that's what I'm using :)

It's fine if you want the resources allocated for the entire duration that the program is running, but that's what I'm trying to avoid. So, I allocate when help is requested, and want to deallocate when the user has finished with it.

Btw, there seems to be a bug in your class, where if you click "help" any subsequent accesses will try to open nodes in help.guide instead of the original AmigaGuide. Re-initialising also fixes that problem.
chris
 
Posts: 551
Joined: Sat Jun 18, 2011 12:05 pm

Re: Notification when Amigaguide closed?

Postby trixie » Tue Feb 11, 2014 10:44 am

@chris

It's fine if you want the resources allocated for the entire duration that the program is running, but that's what I'm trying to avoid. So, I allocate when help is requested, and want to deallocate when the user has finished with it.

Ah, I see. Never thought of a dynamic allocation like that, doesn't make all too much sense to me - there's usually one help file for one program, and the help should be accessible throughout program runtime. That's why my help allocation and deallocation coincides with program startup and exit, respectively.

Btw, there seems to be a bug in your class, where if you click "help" any subsequent accesses will try to open nodes in help.guide instead of the original AmigaGuide.

I'm not sure I understand - what do you mean by "help.guide" and "the original AmigaGuide" exactly? Also, do you set any context array through the AMIGAGUIDE_ContextArray tag? The help invocation call differs internally in the presence of a context array, so I need to know if you use one or not.

Re-initialising also fixes that problem.

Re-initialising how exactly, what do you do precisely? More specific info will greatly help me locate the bug (which I'll be only too glad to fix of course). Thanks!
Smoke me a kipper, I'll be back for breakfast!

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon R5 230 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 373
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Notification when Amigaguide closed?

Postby chris » Tue Feb 11, 2014 11:13 am

trixie wrote:Ah, I see. Never thought of a dynamic allocation like that, doesn't make all too much sense to me - there's usually one help file for one program, and the help should be accessible throughout program runtime. That's why my help allocation and deallocation coincides with program startup and exit, respectively.


It is accessible throughout program runtime, it just isn't using resources whilst it's not open.

Btw, there seems to be a bug in your class, where if you click "help" any subsequent accesses will try to open nodes in help.guide instead of the original AmigaGuide.

I'm not sure I understand - what do you mean by "help.guide" and "the original AmigaGuide" exactly? Also, do you set any context array through the AMIGAGUIDE_ContextArray tag? The help invocation call differs internally in the presence of a context array, so I need to know if you use one or not.


help.guide is the guide which opens when you click "Help" from within AmigaGuide.
The original AmigaGuide is the one specified using AMIGAUIDE_Name
Yes, I'm using a context array.

Re-initialising how exactly, what do you do precisely?


I don't, because I can't, but freeing and re-initialising the class would fix it because it will think it is a brand new session.
chris
 
Posts: 551
Joined: Sat Jun 18, 2011 12:05 pm

Re: Notification when Amigaguide closed?

Postby trixie » Tue Feb 11, 2014 11:43 am

@chris

It is accessible throughout program runtime, it just isn't using resources whilst it's not open.

AmigaGuide may not be designed for that, it has all sorts of shortages here and there.

help.guide is the guide which opens when you click "Help" from within AmigaGuide.

I see. Never tested this one to be honest - will look into it as soon as I get my loaned Sam up and running (hopefully later this week; looks like I'll need to buy a new monitor because the one I got doesn't accept the Sam's video signal, no matter what I try).
Smoke me a kipper, I'll be back for breakfast!

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon R5 230 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 373
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Notification when Amigaguide closed?

Postby chris » Tue Feb 11, 2014 12:08 pm

trixie wrote:AmigaGuide may not be designed for that, it has all sorts of shortages here and there.



No reason why not; ALL it needs to do is send a message to the existing msgport when the async OpenAmigaGuide call returns.
chris
 
Posts: 551
Joined: Sat Jun 18, 2011 12:05 pm

Next

Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 1 guest