Bug in SetWindowPointer(... WA_Pointertype)

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
blmara
Posts: 76
Joined: Thu Jun 23, 2011 9:03 am
Location: Vantaa, Finland

Bug in SetWindowPointer(... WA_Pointertype)

Post by blmara »

Hi!

After changing my application's window pointer code to use the new SDK's default pointers i.e. IIntuition->SetWindowPointer(win,WA_PointerType,...) I noticed that my application would hang with some pointer selections (like POINTERTYPE_SELECT). I confirmed the problem with this tag with this modified window.c example from SDK. Clicking the "Click me" gadget will change pointer until the POINTERTYPE_PEN, which hangs the system completely. Note: Code outputs the used pointertype with DebugPrintF, easily seen with Sashimi.

Code: Select all

/* Window pointer Example
gcc -o Window testWindow.c -lauto
quit
*/

/**
 **  modified Window.c -- Window Example.
 **
 **  Simple window.class example used to test newer features.
**   Added code for SetWindowPointer testing
 **/

#include <dos/dos.h>
#include <classes/window.h>
#include <gadgets/button.h>
#include <gadgets/layout.h>
#include <intuition/pointerclass.h>

#include <proto/intuition.h>
#include <proto/exec.h>
#include <proto/window.h>
#include <proto/layout.h>
#include <proto/button.h>

enum
{
    WID_MAIN = 0,
    WID_LAST
};

enum
{
    OID_MAIN = 0,
    OID_LAST
};

enum {
   GAD_CLICKME = 0,
   GAD_LAST
};

int main()
{
    // Make sure class files were loaded.
    if ( WindowBase == NULL || LayoutBase == NULL || ButtonBase == NULL)
    {
        return RETURN_FAIL;
    }

    struct Window *windows[WID_LAST];
    Object *objects[OID_LAST];
    uint32 pointertype = POINTERTYPE_NORMAL;

    struct MsgPort *AppPort = IExec->AllocSysObjectTags(ASOT_PORT, TAG_DONE);

    if ( AppPort != NULL )
    {
        objects[OID_MAIN] = IIntuition->NewObject(NULL, "window.class",
            WA_ScreenTitle, "Window Example",
            WA_Title, "Window Example",
            WA_Activate, TRUE,
            WA_DepthGadget, TRUE,
            WA_DragBar, TRUE,
            WA_CloseGadget, TRUE,
            WA_SizeGadget, TRUE,

            // If on the Workbench screen, this tells window.class that
            // we can handle the iconify/uniconify when changing screens.
            WINDOW_Iconifiable, TRUE,

            WINDOW_AppPort, AppPort,
            WINDOW_Position, WPOS_CENTERMOUSE,
            WINDOW_Layout, IIntuition->NewObject(NULL, "layout.gadget",
                LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
                LAYOUT_SpaceOuter, TRUE,
                LAYOUT_DeferLayout, TRUE,
                LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget",
                    GA_Text, "Click Me",
		    GA_ID,GAD_CLICKME,
		    GA_RelVerify,TRUE,
                TAG_DONE),
           TAG_DONE),
        TAG_DONE);

        if (objects[OID_MAIN] != NULL)
        {
            //  Open the window.
            windows[WID_MAIN] = (struct Window *)IIntuition->IDoMethod(objects[OID_MAIN], WM_OPEN);

            if (windows[WID_MAIN] != NULL)
            {
                // Obtain the window wait signal mask.

                uint32 signal = 0;
                IIntuition->GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);

                // Input Event Loop

                BOOL done = FALSE;

                while (!done)
                {
                    uint32 wait = IExec->Wait(signal | SIGBREAKF_CTRL_C);

                    if ( wait & SIGBREAKF_CTRL_C )
                    {
                        done = TRUE;
                        break;
                    }

                    if ( wait & signal )
                    {
                        uint32 result = WMHI_LASTMSG;
                        int16 code = 0;

                        while ((result = IIntuition->IDoMethod(objects[OID_MAIN], WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
                        {
                            switch (result & WMHI_CLASSMASK)
                            {
                                case WMHI_CLOSEWINDOW:
                                    windows[WID_MAIN] = NULL;
                                    done = TRUE;
                                    break;

                                case WMHI_ICONIFY:
                                    IIntuition->IDoMethod(objects[OID_MAIN], WM_ICONIFY);
                                    windows[WID_MAIN] = NULL;
                                    break;

                                case WMHI_UNICONIFY:
                                    windows[WID_MAIN] = (struct Window *)IIntuition->IDoMethod(objects[OID_MAIN], WM_OPEN);
                                    break;

				case WMHI_GADGETUP:
					switch (result & WMHI_GADGETMASK)
					{
						case GAD_CLICKME:
							IExec->DebugPrintF("Setting Window pointer type %ld!\n",pointertype);
							IIntuition->SetWindowPointer(windows[WID_MAIN],WA_PointerType,pointertype,TAG_DONE);
							pointertype++;
							if (pointertype == POINTERTYPE_COUNT)
								pointertype = POINTERTYPE_NORMAL;
							break;


					}
					break;
                            }
                        }
                    }
                }
            }

            /* Disposing of the window object will also close the window if it is
             * already opened, and it will dispose of the layout object attached to it.
             */
            IIntuition->DisposeObject(objects[OID_MAIN]);
        }

    }

    IExec->FreeSysObject(ASOT_PORT, AppPort);

    return RETURN_OK;
}
Marko
Marko
zzd10h
Posts: 546
Joined: Sun Sep 16, 2012 5:40 am
Location: France

Re: Bug in SetWindowPointer(... WA_Pointertype)

Post by zzd10h »

I was faster than you to freeze my x1000 :)

Look here :
http://forum.hyperion-entertainment.biz ... =27&t=3159
http://apps.amistore.net/zTools
X1000 - AmigaOS 4.1.6 / 4.1 FE
blmara
Posts: 76
Joined: Thu Jun 23, 2011 9:03 am
Location: Vantaa, Finland

Re: Bug in SetWindowPointer(... WA_Pointertype)

Post by blmara »

zzd10h wrote:I was faster than you to freeze my x1000 :)
You really were :D

Marko
Marko
Post Reply