VirtualBox

Changeset 26439 in vbox


Ignore:
Timestamp:
Feb 11, 2010 3:38:12 PM (15 years ago)
Author:
vboxsync
Message:

Frontends/SDL+Headless: fix VirtualBox callback registration leak

Location:
trunk/src/VBox/Frontends
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r26322 r26439  
    832832    ComPtr<ISession> session;
    833833    bool fSessionOpened = false;
     834    VirtualBoxCallback *vboxCallback = NULL;
    834835
    835836    do
     
    10181019
    10191020        /* VirtualBox callback registration. */
    1020         VirtualBoxCallback *vboxCallback = new VirtualBoxCallback();
     1021        vboxCallback = new VirtualBoxCallback();
    10211022        vboxCallback->AddRef();
    10221023        CHECK_ERROR(virtualBox, RegisterCallback(vboxCallback));
     
    11421143    while (0);
    11431144
     1145    /* VirtualBox callback unregistration. */
     1146    if (vboxCallback)
     1147    {
     1148        vboxCallback->AddRef();
     1149        CHECK_ERROR(virtualBox, UnregisterCallback(vboxCallback));
     1150        vboxCallback->Release();
     1151    }
     1152
    11441153    /* No more access to the 'console' object, which will be uninitialized by the next session->Close call. */
    11451154    gConsole = NULL;
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r26429 r26439  
    13931393    }
    13941394
    1395     do
     1395    /* NOTE: do not convert the following scope to a "do {} while (0);", as
     1396     * this would make it all too tempting to use "break;" incorrectly - it
     1397     * would skip over the cleanup. */
    13961398    {
    13971399    // scopes all the stuff till shutdown
     
    14011403    ComPtr <ISession> session;
    14021404    bool sessionOpened = false;
     1405    EventQueue* eventQ = com::EventQueue::getMainEventQueue();
    14031406
    14041407    rc = virtualBox.createLocalObject (CLSID_VirtualBox);
     
    14111414        else
    14121415            RTPrintf("Failed to create VirtualBox object! No error information available (rc = 0x%x).\n", rc);
    1413         break;
     1416        goto leave;
    14141417    }
    14151418    rc = session.createInprocObject (CLSID_Session);
     
    14171420    {
    14181421        RTPrintf("Failed to create session object, rc = 0x%x!\n", rc);
    1419         break;
    1420     }
    1421 
    1422     EventQueue* eventQ = com::EventQueue::getMainEventQueue();
     1422        goto leave;
     1423    }
    14231424
    14241425    /*
     
    17521753
    17531754            ComPtr<ISnapshot> pCurrentSnapshot;
    1754             CHECK_ERROR_BREAK(gMachine, COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam()));
     1755            CHECK_ERROR(gMachine, COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam()));
     1756            if (FAILED(rc))
     1757                goto leave;
    17551758
    17561759            CHECK_ERROR(gConsole, RestoreSnapshot(pCurrentSnapshot, gProgress.asOutParam()));
     
    27572760           )
    27582761       )
     2762    do
    27592763    {
    27602764        cbConsoleImpl->ignorePowerOffEvents(true);
    2761         ComPtr <IProgress> progress;
     2765        ComPtr<IProgress> progress;
    27622766        CHECK_ERROR_BREAK(gConsole, PowerDown(progress.asOutParam()));
    2763         CHECK_ERROR_BREAK (progress, WaitForCompletion (-1));
     2767        CHECK_ERROR_BREAK(progress, WaitForCompletion(-1));
    27642768        BOOL completed;
    2765         CHECK_ERROR_BREAK (progress, COMGETTER(Completed) (&completed));
     2769        CHECK_ERROR_BREAK(progress, COMGETTER(Completed)(&completed));
    27662770        ASSERT (completed);
    27672771        LONG hrc;
    2768         CHECK_ERROR_BREAK (progress, COMGETTER(ResultCode) (&hrc));
     2772        CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&hrc));
    27692773        if (FAILED(hrc))
    27702774        {
     
    27772781            break;
    27782782        }
    2779     }
     2783    } while (0);
    27802784
    27812785    /*
     
    28662870        RTLdrClose(gLibrarySDL_ttf);
    28672871#endif
     2872
     2873    /* VirtualBox callback unregistration. */
     2874    if (!virtualBox.isNull() && !callback.isNull())
     2875        virtualBox->UnregisterCallback(callback);
     2876
    28682877    LogFlow(("Releasing machine, session...\n"));
    28692878    gMachine = NULL;
     
    28752884    ////////////////////////////////////////////////////////////////////////////
    28762885    }
    2877     while (0);
    28782886
    28792887    /* Must be before com::Shutdown() */
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