Clicking on close window does not close it

16 posts / 0 new
Last post
Coder
Coder's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2010-12-01 00:34
Clicking on close window does not close it
Hi all, I have a problem with my code and I just can't find the bug. I open my window but when I close it nothing happens. Below is a snippet of the code. After doing some testing I can see it never reaches the part "while(( result = IIntuition->IDoMethod( winobj, WM_HANDLEINPUT, &code )) != WMHI_LASTMSG )". If I place the code to break from the program using CTRL C between the two while's it will do that. I stared at a dozen examples and I just can't find the cause. while( !done ) { while(( result = IIntuition->IDoMethod( winobj, WM_HANDLEINPUT, &code )) != WMHI_LASTMSG ) { switch( result & WMHI_CLASSMASK ) { case WMHI_CLOSEWINDOW: done = TRUE; break; } } } Coder
thomas
thomas's picture
Offline
Last seen: 2 hours 29 min ago
Joined: 2011-05-16 14:23
This code is badly missing a
This code is badly missing a Wait(). Like it is now it does a busy-loop. Apart from that the code is correct. Your problem is not here. Maybe "winobj" is not initialised correctly. Or "IIntuition".
xenic
xenic's picture
Offline
Last seen: 4 months 1 day ago
Joined: 2011-05-07 04:52
@Coder Assuming there is a
@Coder Assuming there is a Wait() somewhere before the loop in your example (we don't want busy-looping on Amiga) then I would ask if you initialized the "done" variable (done = FALSE) before entering the while(!done) loop. The "while((result=" part would never be executed if the "done" variable is set to TRUE by a previous code section.
X1000 - OS 4.1FE
Rigo
Rigo's picture
Offline
Last seen: 17 hours 27 min ago
Joined: 2011-01-24 21:55
There are various examples
There are various examples included with the SD in examples/reaction/os4_examples. Check those out to see what the event loop code should look like. Simon
salass00
salass00's picture
Offline
Last seen: 3 hours 14 min ago
Joined: 2011-02-03 11:27
@Coder Make sure that you
@Coder Make sure that you set WA_IDCMP to IDCMP_CLOSEWINDOW when you create the window object so that intuition knows that you are interested in hearing about close window events.
Coder
Coder's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2010-12-01 00:34
@salass00 Is
@salass00 Is WMHI_CLOSEWINDOW not taking care of this? Coder
Coder
Coder's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2010-12-01 00:34
@thomas The wait() is there.
@thomas The wait() is there. winobj and IIntuition seems to be correct compared to example code. Coder
Coder
Coder's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2010-12-01 00:34
@xenic I have set done to
@xenic I have set done to FALSE. Coder
Coder
Coder's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2010-12-01 00:34
Hi Simon, I use the new way
Hi Simon, I use the new way that Trixie described in his guide. So the examples use a different way like RA_handleinput for example. Coder
Rigo
Rigo's picture
Offline
Last seen: 17 hours 27 min ago
Joined: 2011-01-24 21:55
RA_HandleInput is just a
RA_HandleInput is just a macro which is defined in <reaction/reaction_macros.h> Simon
salass00
salass00's picture
Offline
Last seen: 3 hours 14 min ago
Joined: 2011-02-03 11:27
@Coder Is WMHI_CLOSEWINDOW
@Coder
Is WMHI_CLOSEWINDOW not taking care of this?
No, how could it? The WA_IDCMP is a mask telling intuition which classes of IDCMP message that it should send to your window. If the IDCMP_CLOSEWINDOW bit isn't set you won't get any close window events and your "case WMHI_CLOSEWINDOW:" will never happen.
thomas
thomas's picture
Offline
Last seen: 2 hours 29 min ago
Joined: 2011-05-16 14:23
No, how could it? The
No, how could it? The WA_IDCMP is a mask telling intuition which classes of IDCMP message that it should send to your window. If the IDCMP_CLOSEWINDOW bit isn't set you won't get any close window events and your "case WMHI_CLOSEWINDOW:" will never happen.
This is true for normal Intuition windows, but window.class automatically sets IDCMP_CLOSEWINDOW if WFLG_CLOSEGADGET is set. You only need to set *additional* IDCMP flags through WA_IDCMP. For example IDCMP_VANILLAKEY needs to be set explicitly.
Coder
Coder's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2010-12-01 00:34
I am starting to believe the
I am starting to believe the problem lies in the below snippet of code. /* Obtain window pointer and signal mask from the window object. */ IIntuition->GetAttrs(winObj, WINDOW_Window, (uint32 *)&window, WINDOW_SigMask, &sigMask, TAG_END); Because CTRL-C does set done on TRUE and closes the window. Coder
thomas
thomas's picture
Offline
Last seen: 2 hours 29 min ago
Joined: 2011-05-16 14:23
You major problem is that you
You major problem is that you don't have the overview over the whole code. If you only look at one statement you will never find the mistake. Of course this statement is syntactically correct and it does what it should do. But do you know what it shall do? Did you understand what it is good for and where in the program it should reside? Your error can be everywhere. It can even be that the statement is not in the right place of the code. But you'll find this out only if you look at the entire code at once and not at only one statement at a time. So please, either quote your entire program here. Or if you find it too big or too confidential, then please put together a small complete example which behaves the same as your problem program. Often one finds the mistake by oneself while trying to recreate the problem.
trixie
trixie's picture
Offline
Last seen: 2 months 1 week ago
Joined: 2011-02-03 13:58
@coder I use the new way
@coder
I use the new way that Trixie described in his guide. So the examples use a different way like RA_handleinput for example.
The ReAction BOOPSI class extension does handle the input loop differently than the standard Intuition. The loop works well and is well documented by the OS4 SDK examples (my tutorial barely touches the subject and only mentions to avoid the macro). If it looks like you have everything in place than chances are your problem lies elsewhere. We really need to see the entire code to help you. But you gave me some inspiration for a new tutorial :-) I'll try to write something on the input loop during X-mastime.
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition Author of WordNet for OS4
Coder
Coder's picture
Offline
Last seen: 7 years 5 months ago
Joined: 2010-12-01 00:34
I am going through my code
I am going through my code with precision to find the bug. I already eliminated some possible causes and I am sure I will find it soon. Happy Christmas everyone! Coder
Log in or register to post comments