message cleanup
message cleanup
While searching through the GUI examples in the SDK, I noticed that none of them appear to be cleaning up queued Intuition messages before exiting. Can I assume that Reaction returns any queued messages when you dispose the window object?
AmigaOne X1000 with 2GB memory - OS4.1 FE
- tonyw
- AmigaOS Core Developer
- Posts: 1479
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: message cleanup
While that may happen (and I don't know the answer to the question), it is good practice to clean up any messages that arrive at your port while you have it open, "during your watch". To leave them for someone else to clean up afterward would be Not A Good Idea.
cheers
tony
tony
Re: message cleanup
AFAIK in a ReAction input loop you don't directly deal with any messages arriving at the window port. You just Wait() for your signal and then while-loop the WM_HANDLEINPUT method until it returns WMHI_LASTMSG. Without knowing the actual internals of the Window Class, I'd bet the messages are duly cleaned up inside the method.
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
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
Re: message cleanup
If you're right then all the GUI examples in the SDK need to be fixed with a message cleanup.tonyw wrote:While that may happen (and I don't know the answer to the question), it is good practice to clean up any messages that arrive at your port while you have it open, "during your watch". To leave them for someone else to clean up afterward would be Not A Good Idea.
AmigaOne X1000 with 2GB memory - OS4.1 FE
Re: message cleanup
@xenic
I don't think 15+ years have passed without anybody noticing that all ReAction programs do not clean up their messages.
I don't think 15+ years have passed without anybody noticing that all ReAction programs do not clean up their messages.
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
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
Re: message cleanup
True but the problem is that most examples allow the input loop to respond to messages after a window close message or an error that sets the "done=TRUE" flag.. Here is a snippet of code to demonstrate what I mean:trixie wrote:AFAIK in a ReAction input loop you don't directly deal with any messages arriving at the window port. You just Wait() for your signal and then while-loop the WM_HANDLEINPUT method until it returns WMHI_LASTMSG. Without knowing the actual internals of the Window Class, I'd bet the messages are duly cleaned up inside the method.
Code: Select all
while (!done)
{
Wait(waitmask);
while ((input = RA_HandleInput(windowobj,&code)) != WMHI_LASTMSG)
{
switch (input & WMHI_CLASSMASK)
{
case WMHI_CLOSEWINDOW:
done = TRUE;
break;
case WMHI_RAWKEY:
{
switch( code )
{
case 0x25:
{
<function that does stuff>
break;
}
}
A test should be added to prevent any code being executed after "done=TRUE" is set. I think it should look like this:
Code: Select all
while (!done)
{
Wait(waitmask);
while ((input = RA_HandleInput(windowobj,&code)) != WMHI_LASTMSG)
{
if (done == TRUE)
{
continue;
}
switch (input & WMHI_CLASSMASK)
{
case WMHI_CLOSEWINDOW:
done = TRUE;
break;
case WMHI_RAWKEY:
{
switch( code )
{
case 0x25:
{
<function that does stuff>
break;
}
}
AmigaOne X1000 with 2GB memory - OS4.1 FE
Re: message cleanup
@xenic
The people who have worked on ReAction in the past decade - Rigo, Steven Solie, Fredrik Wikstrom - would surely be able to shed some light on this.
The people who have worked on ReAction in the past decade - Rigo, Steven Solie, Fredrik Wikstrom - would surely be able to shed some light on this.
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
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
- tonyw
- AmigaOS Core Developer
- Posts: 1479
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: message cleanup
@xenic
That is true, but you could in theory receive a message from *any* source to the Intuition port - a window close, a resize, an iconify command...
It just goes to show that you should clear out the port message queue before you close the window.
That is true, but you could in theory receive a message from *any* source to the Intuition port - a window close, a resize, an iconify command...
It just goes to show that you should clear out the port message queue before you close the window.
cheers
tony
tony
Re: message cleanup
@tonyw
But who says the WM_CLOSE and OM_DISPOSE methods invoked on the window object do not perform the message clean-up? Frankly, the Window Class would have to have been written by a monkey to omit such a crucial step.It just goes to show that you should clear out the port message queue before you close the window.
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
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
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: message cleanup
RTFA (Read the fantabulous auitodocs)xenic wrote:While searching through the GUI examples in the SDK, I noticed that none of them appear to be cleaning up queued Intuition messages before exiting. Can I assume that Reaction returns any queued messages when you dispose the window object?
From Close Window()NAME
WM_CLOSE -- Close the window.
--8<---
If the window is sharing a message
port with another window the port will be cleaned of messages
intended for this Window.
--8<-----
Second paragraph is dealt with by the earlier statement about WM_CLOSE.FUNCTION
Closes an Intuition window. Unlinks it from the system, deallocates
its memory, and makes it disappear.
When this function is called, all IDCMP messages which have been sent
to your window are deallocated. If the window had shared a message
Port with other windows, you must be sure that there are no unreplied
messages for this window in the message queue.
If you are using plain intuition windows, with a shared user port, things might get a little more complex, but the OP was about Reaction, so I'm not going to get my hands dirty with that, in this quickl reply ...