VirtualBox

Ignore:
Timestamp:
Feb 14, 2007 11:03:34 AM (18 years ago)
Author:
vboxsync
Message:

1803: FE/Qt leaks memory on Windows

It looks like QCursor uses HCURSOR handle “as is” without copying, so it is not correct to destroy WinAPI HCURSOR just after setting cursor to console viewport.
Unfortunately QCursor will not destroy icon under HCURSOR handle during self-destruction so it is necessary:

  1. to make VBoxConsoleView class member – HCURSOR handle,
  2. to destroy HCURSOR handle after new cursor is set for viewport,
  3. to destroy HCURSOR handle if it is not required any more (upon VBoxConsoleView destruction).
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r382 r896  
    8383
    8484    void onFullscreenChange (bool on);
    85    
     85
    8686    void fixModifierState (LONG *codes, uint *count);
    8787
     
    206206    VBoxDefs::RenderMode mode;
    207207
     208#if defined(Q_WS_WIN)
     209    HCURSOR mAlphaCursor;
     210#endif
     211
    208212#if defined (VBOX_GUI_USE_REFRESH_TIMER)
    209213    QPixmap pm;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r649 r896  
    302302    {
    303303        QApplication::postEvent (
    304             view, new RuntimeErrorEvent (!!fatal, QString::fromUcs2 (id), 
     304            view, new RuntimeErrorEvent (!!fatal, QString::fromUcs2 (id),
    305305                                         QString::fromUcs2 (message)));
    306306        return S_OK;
     
    355355    , muCapsLockAdaptionCnt (2)
    356356    , mode (rm)
     357#if defined(Q_WS_WIN)
     358    , mAlphaCursor (NULL)
     359#endif
    357360{
    358361    Assert (!cconsole.isNull() &&
     
    477480        UnhookWindowsHookEx (g_kbdhook);
    478481    g_view = 0;
     482    if (mAlphaCursor)
     483        DestroyIcon (mAlphaCursor);
    479484#endif
    480485
     
    672677{
    673678    /// @todo (r=dmik) not currently sure is this method necessary to
    674     //  fix fullscreen toggle problems (invalid areas) on Linux/SDL   
     679    //  fix fullscreen toggle problems (invalid areas) on Linux/SDL
    675680//    if (fb)
    676681//    {
     
    21552160        HBITMAP hBitmap;
    21562161        void *lpBits;
    2157         HCURSOR hAlphaCursor = NULL;
    21582162
    21592163        ::ZeroMemory (&bi, sizeof (BITMAPV5HEADER));
     
    22622266            ii.hbmColor = hBitmap;
    22632267
    2264             hAlphaCursor = CreateIconIndirect (&ii);
     2268            HCURSOR hAlphaCursor = CreateIconIndirect (&ii);
    22652269            Assert (hAlphaCursor);
    22662270            if (hAlphaCursor)
     
    22682272                viewport()->setCursor (QCursor (hAlphaCursor));
    22692273                ok = true;
    2270                 DestroyIcon (hAlphaCursor);
     2274                if (mAlphaCursor)
     2275                    DestroyIcon (mAlphaCursor);
     2276                mAlphaCursor = hAlphaCursor;
    22712277            }
    22722278        }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette