VirtualBox

Changeset 22305 in vbox for trunk/src/VBox/Frontends/VBoxSDL


Ignore:
Timestamp:
Aug 17, 2009 5:37:41 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51179
Message:

Main: generic callback wrappers mechanism

File:
1 edited

Legend:

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

    r22173 r22305  
    854854    uint32_t memorySize = 0;
    855855    uint32_t vramSize = 0;
    856     VBoxSDLCallback *callback = NULL;
    857     VBoxSDLConsoleCallback *consoleCallback = NULL;
     856    VBoxSDLCallback *cbVBoxImpl = NULL;
     857    /* wrapper around above object */
     858    ComPtr<IVirtualBoxCallback> callback;
     859    VBoxSDLConsoleCallback *cbConsoleImpl = NULL;
     860    ComPtr<IConsoleCallback> consoleCallback;
     861
    858862    bool fFullscreen = false;
    859863    bool fResizable = true;
     
    18501854#endif
    18511855
     1856
    18521857    for (ULONG i = 0; i < gcMonitors; i++)
    18531858    {
    18541859        // register our framebuffer
    18551860        rc = gDisplay->SetFramebuffer(i, gpFramebuffer[i]);
    1856         if (rc != S_OK)
     1861        if (FAILED(rc))
    18571862        {
    18581863            RTPrintf("Error: could not register framebuffer object!\n");
     
    18661871
    18671872    // register a callback for global events
    1868     callback = new VBoxSDLCallback();
    1869     callback->AddRef();
     1873    cbVBoxImpl = new VBoxSDLCallback();
     1874    rc = createCallbackWrapper((IVirtualBoxCallback*)cbVBoxImpl, callback.asOutParam());
     1875    if (FAILED(rc))
     1876        goto leave;
    18701877    virtualBox->RegisterCallback(callback);
    18711878
    18721879    // register a callback for machine events
    1873     consoleCallback = new VBoxSDLConsoleCallback();
    1874     consoleCallback->AddRef();
     1880    cbConsoleImpl = new VBoxSDLConsoleCallback();
     1881    rc = createCallbackWrapper((IConsoleCallback*)cbConsoleImpl, consoleCallback.asOutParam());
     1882    if (FAILED(rc))
     1883        goto leave;
    18751884    gConsole->RegisterCallback(consoleCallback);
    18761885    // until we've tried to to start the VM, ignore power off events
    1877     consoleCallback->ignorePowerOffEvents(true);
     1886    cbConsoleImpl->ignorePowerOffEvents(true);
    18781887
    18791888#ifdef VBOX_WITH_VRDP
     
    21722181    // accept power off events from now on because we're running
    21732182    // note that there's a possible race condition here...
    2174     consoleCallback->ignorePowerOffEvents(false);
     2183    cbConsoleImpl->ignorePowerOffEvents(false);
    21752184
    21762185    rc = gConsole->COMGETTER(Keyboard)(gKeyboard.asOutParam());
     
    26852694        && machineState == MachineState_Running)
    26862695    {
    2687         consoleCallback->ignorePowerOffEvents(true);
     2696        cbConsoleImpl->ignorePowerOffEvents(true);
    26882697        ComPtr <IProgress> progress;
    26892698        CHECK_ERROR_BREAK(gConsole, PowerDown(progress.asOutParam()));
     
    27922801    gMachine = NULL;
    27932802    session = NULL;
    2794     LogFlow(("Releasing callback handlers...\n"));
    2795     if (callback)
    2796         callback->Release();
    2797     if (consoleCallback)
    2798         consoleCallback->Release();
    2799 
    28002803    LogFlow(("Releasing VirtualBox object...\n"));
    28012804    virtualBox = NULL;
Note: See TracChangeset for help on using the changeset viewer.

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