updateWindowContainingMouse bug

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

ianstangoe
Quite a regular
Quite a regular
Posts: 79
Joined: Wed Jan 09, 2008 11:06

updateWindowContainingMouse bug

Postby ianstangoe » Tue Aug 17, 2010 14:15

Hi CE,

I've discovered a bug in this function which fatally crashes, this is with the latest stable branch code.

Basically when I hide all my menu windows getCommonAncestor() is passed a NULL pointer for d_wndWithMouse here:

Code: Select all

    // do the 'area' version of the events
    Window* root = getCommonAncestor(oldWindow, d_wndWithMouse);

    if (oldWindow)
        notifyMouseTransition(root, oldWindow, &Window::onMouseLeavesArea, ma);

    if (d_wndWithMouse)
        notifyMouseTransition(root, d_wndWithMouse, &Window::onMouseEntersArea, ma);


getCommonAncestor() doesn't check for this and neither does the above code, I'm not sure what the desired behaviour should be in this case, it would seem logical to still notify the system that the mouse has left a window... :?

I made the following changes which appear to work fine for me although you'll know more about the notification process :)

Code: Select all

//----------------------------------------------------------------------------//
Window* System::getCommonAncestor(Window* w1, Window* w2)
{
   if (!w1 || !w2)
   {
      if (!w1 && !w2)   
         return 0;

      if (w1)         
         return w1;

      return w2;
   }

    if (w1 == w2)
        return w1;

    // make sure w1 is always further up
    if (w1 && w1->isAncestor(w2))
        return w2;

    while (w1)
    {
        if (w2->isAncestor(w1))
            break;

        w1 = w1->getParent();
    }

    return w1;
}

updateWindowContainingMouse():

Code: Select all

    // do the 'area' version of the events
    Window* root = getCommonAncestor(oldWindow, d_wndWithMouse);

    if (root && oldWindow)
        notifyMouseTransition(root, oldWindow, &Window::onMouseLeavesArea, ma);

    if (root && d_wndWithMouse)
        notifyMouseTransition(root, d_wndWithMouse, &Window::onMouseEntersArea, ma);


HTH.

Ian.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: updateWindowContainingMouse bug

Postby CrazyEddie » Tue Aug 17, 2010 18:45

Thanks for catching this one - I'll get a fix in for it tomorrow :D

CE.


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 13 guests