VirtualBox

Changeset 41595 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Jun 6, 2012 9:58:30 AM (13 years ago)
Author:
vboxsync
Message:

Main/Machine+Display: do not ignore the error code from DisplayMakePNG, create a nice error message out of it to help tracking down the root cause if it fails for no obvious reason

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r41492 r41595  
    241241            /* Prepare a small thumbnail and a PNG screenshot. */
    242242            displayMakeThumbnail(pu8Data, cx, cy, &pu8Thumbnail, &cbThumbnail, &cxThumbnail, &cyThumbnail);
    243             DisplayMakePNG(pu8Data, cx, cy, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 1);
     243            rc = DisplayMakePNG(pu8Data, cx, cy, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 1);
     244            if (RT_FAILURE(rc))
     245            {
     246                if (pu8PNG)
     247                {
     248                    RTMemFree(pu8PNG);
     249                    pu8PNG = NULL;
     250                }
     251                cbPNG = 0;
     252                cxPNG = 0;
     253                cyPNG = 0;
     254            }
    244255
    245256            /* This can be called from any thread. */
    246             that->mpDrv->pUpPort->pfnFreeScreenshot (that->mpDrv->pUpPort, pu8Data);
     257            that->mpDrv->pUpPort->pfnFreeScreenshot(that->mpDrv->pUpPort, pu8Data);
    247258        }
    248259    }
     
    23232334            int iDeltaLine = cx * 4;
    23242335
    2325             BitmapScale32 (dst,
    2326                            dstW, dstH,
    2327                            src,
    2328                            iDeltaLine,
    2329                            srcW, srcH);
     2336            BitmapScale32(dst,
     2337                          dstW, dstH,
     2338                          src,
     2339                          iDeltaLine,
     2340                          srcW, srcH);
    23302341        }
    23312342
     
    23332344        {
    23342345            /* This can be called from any thread. */
    2335             pDrv->pUpPort->pfnFreeScreenshot (pDrv->pUpPort, pu8Data);
     2346            pDrv->pUpPort->pfnFreeScreenshot(pDrv->pUpPort, pu8Data);
    23362347        }
    23372348        else
     
    23442355}
    23452356
    2346 STDMETHODIMP Display::TakeScreenShot (ULONG aScreenId, BYTE *address, ULONG width, ULONG height)
     2357STDMETHODIMP Display::TakeScreenShot(ULONG aScreenId, BYTE *address, ULONG width, ULONG height)
    23472358{
    23482359    /// @todo (r=dmik) this function may take too long to complete if the VM
     
    23522363    //  within the Console lock to make it atomic).
    23532364
    2354     LogRelFlowFunc (("address=%p, width=%d, height=%d\n",
    2355                   address, width, height));
     2365    LogRelFlowFunc(("address=%p, width=%d, height=%d\n",
     2366                    address, width, height));
    23562367
    23572368    CheckComArgNotNull(address);
     
    23702381    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    23712382
    2372     CHECK_CONSOLE_DRV (mpDrv);
     2383    CHECK_CONSOLE_DRV(mpDrv);
    23732384
    23742385    Console::SafeVMPtr pVM(mParent);
     
    23772388    HRESULT rc = S_OK;
    23782389
    2379     LogRelFlowFunc (("Sending SCREENSHOT request\n"));
     2390    LogRelFlowFunc(("Sending SCREENSHOT request\n"));
    23802391
    23812392    /* Release lock because other thread (EMT) is called and it may initiate a resize
     
    23982409                      tr("Could not take a screenshot (%Rrc)"), vrc);
    23992410
    2400     LogRelFlowFunc (("rc=%08X\n", rc));
     2411    LogRelFlowFunc(("rc=%08X\n", rc));
    24012412    return rc;
    24022413}
    24032414
    2404 STDMETHODIMP Display::TakeScreenShotToArray (ULONG aScreenId, ULONG width, ULONG height,
    2405                                              ComSafeArrayOut(BYTE, aScreenData))
    2406 {
    2407     LogRelFlowFunc (("width=%d, height=%d\n",
    2408                   width, height));
     2415STDMETHODIMP Display::TakeScreenShotToArray(ULONG aScreenId, ULONG width, ULONG height,
     2416                                            ComSafeArrayOut(BYTE, aScreenData))
     2417{
     2418    LogRelFlowFunc(("width=%d, height=%d\n", width, height));
    24092419
    24102420    CheckComArgOutSafeArrayPointerValid(aScreenData);
     
    24232433    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    24242434
    2425     CHECK_CONSOLE_DRV (mpDrv);
     2435    CHECK_CONSOLE_DRV(mpDrv);
    24262436
    24272437    Console::SafeVMPtr pVM(mParent);
     
    24302440    HRESULT rc = S_OK;
    24312441
    2432     LogRelFlowFunc (("Sending SCREENSHOT request\n"));
     2442    LogRelFlowFunc(("Sending SCREENSHOT request\n"));
    24332443
    24342444    /* Release lock because other thread (EMT) is called and it may initiate a resize
     
    24622472        }
    24632473
    2464         com::SafeArray<BYTE> screenData (cbData);
     2474        com::SafeArray<BYTE> screenData(cbData);
    24652475        screenData.initFrom(pu8Data, cbData);
    24662476        screenData.detachTo(ComSafeArrayOutArg(aScreenData));
     
    24752485    RTMemFree(pu8Data);
    24762486
    2477     LogRelFlowFunc (("rc=%08X\n", rc));
     2487    LogRelFlowFunc(("rc=%08X\n", rc));
    24782488    return rc;
    24792489}
    24802490
    2481 STDMETHODIMP Display::TakeScreenShotPNGToArray (ULONG aScreenId, ULONG width, ULONG height,
    2482                                              ComSafeArrayOut(BYTE, aScreenData))
    2483 {
    2484     LogRelFlowFunc (("width=%d, height=%d\n",
    2485                   width, height));
     2491STDMETHODIMP Display::TakeScreenShotPNGToArray(ULONG aScreenId, ULONG width, ULONG height,
     2492                                               ComSafeArrayOut(BYTE, aScreenData))
     2493{
     2494    LogRelFlowFunc(("width=%d, height=%d\n", width, height));
    24862495
    24872496    CheckComArgOutSafeArrayPointerValid(aScreenData);
     
    25002509    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    25012510
    2502     CHECK_CONSOLE_DRV (mpDrv);
     2511    CHECK_CONSOLE_DRV(mpDrv);
    25032512
    25042513    Console::SafeVMPtr pVM(mParent);
     
    25072516    HRESULT rc = S_OK;
    25082517
    2509     LogRelFlowFunc (("Sending SCREENSHOT request\n"));
     2518    LogRelFlowFunc(("Sending SCREENSHOT request\n"));
    25102519
    25112520    /* Release lock because other thread (EMT) is called and it may initiate a resize
     
    25312540        uint32_t cyPNG = 0;
    25322541
    2533         DisplayMakePNG(pu8Data, width, height, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 0);
    2534 
    2535         com::SafeArray<BYTE> screenData (cbPNG);
    2536         screenData.initFrom(pu8PNG, cbPNG);
    2537         RTMemFree(pu8PNG);
    2538 
    2539         screenData.detachTo(ComSafeArrayOutArg(aScreenData));
     2542        vrc = DisplayMakePNG(pu8Data, width, height, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 0);
     2543        if (RT_SUCCESS(vrc))
     2544        {
     2545            com::SafeArray<BYTE> screenData(cbPNG);
     2546            screenData.initFrom(pu8PNG, cbPNG);
     2547            if (pu8PNG)
     2548                RTMemFree(pu8PNG);
     2549
     2550            screenData.detachTo(ComSafeArrayOutArg(aScreenData));
     2551        }
     2552        else
     2553        {
     2554            if (pu8PNG)
     2555                RTMemFree(pu8PNG);
     2556            rc = setError(VBOX_E_IPRT_ERROR,
     2557                          tr("Could not convert screenshot to PNG (%Rrc)"), vrc);
     2558        }
    25402559    }
    25412560    else if (vrc == VERR_NOT_IMPLEMENTED)
     
    25482567    RTMemFree(pu8Data);
    25492568
    2550     LogRelFlowFunc (("rc=%08X\n", rc));
     2569    LogRelFlowFunc(("rc=%08X\n", rc));
    25512570    return rc;
    25522571}
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