VirtualBox

Changeset 90798 in vbox


Ignore:
Timestamp:
Aug 23, 2021 3:59:23 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8161: Runtime UI / UIMachineView: A bit of sanity checks for frame-buffer presence.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r90705 r90798  
    283283    if (   !isFullscreenOrSeamless()
    284284        && uisession()->isGuestSupportsGraphics()
    285         && (   (int)m_pFrameBuffer->width() != size.width()
    286             || (int)m_pFrameBuffer->height() != size.height()
     285        && (   (int)frameBuffer()->width() != size.width()
     286            || (int)frameBuffer()->height() != size.height()
    287287            || uisession()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))
    288288        storeGuestSizeHint(size);
     
    295295        {
    296296            /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes: */
    297             if ((int)m_pFrameBuffer->width() != size.width() || (int)m_pFrameBuffer->height() != size.height())
     297            if ((int)frameBuffer()->width() != size.width() || (int)frameBuffer()->height() != size.height())
    298298            {
    299299                LogRel(("GUI: UIMachineView::sltPerformGuestResize: Auto-pilot resizing screen %d as %dx%d\n",
     
    348348    {
    349349        /* Do not send a hint if nothing has changed to prevent the guest being notified about its own changes: */
    350         if ((int)m_pFrameBuffer->width() != size.width() || (int)m_pFrameBuffer->height() != size.height())
     350        if ((int)frameBuffer()->width() != size.width() || (int)frameBuffer()->height() != size.height())
    351351        {
    352352            LogRel(("GUI: UIMachineView::sltPerformGuestResize: Sending guest size-hint to screen %d as %dx%d\n",
     
    402402        if (   !isFullscreenOrSeamless()
    403403            && uisession()->isGuestSupportsGraphics()
    404             && (   m_pFrameBuffer->width() != uWidth
    405                 || m_pFrameBuffer->height() != uHeight
     404            && (   frameBuffer()->width() != uWidth
     405                || frameBuffer()->height() != uHeight
    406406                || uisession()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))
    407407            storeGuestSizeHint(QSize(uWidth, uHeight));
     
    453453    if (   !isFullscreenOrSeamless()
    454454        && uisession()->isGuestSupportsGraphics()
    455         && (   (int)m_pFrameBuffer->width() != size.width()
    456             || (int)m_pFrameBuffer->height() != size.height()
     455        && (   (int)frameBuffer()->width() != size.width()
     456            || (int)frameBuffer()->height() != size.height()
    457457            || uisession()->isScreenVisible(screenId()) != uisession()->isScreenVisibleHostDesires(screenId())))
    458458        storeGuestSizeHint(size);
     
    473473void UIMachineView::sltHandleNotifyChange(int iWidth, int iHeight)
    474474{
     475    /* Sanity check: */
     476    if (!frameBuffer())
     477        return;
     478
    475479    LogRel2(("GUI: UIMachineView::sltHandleNotifyChange: Screen=%d, Size=%dx%d\n",
    476480             (unsigned long)m_uScreenId, iWidth, iHeight));
     
    570574void UIMachineView::sltHandleNotifyUpdate(int iX, int iY, int iWidth, int iHeight)
    571575{
     576    /* Sanity check: */
     577    if (!frameBuffer())
     578        return;
     579
    572580    /* Prepare corresponding viewport part: */
    573581    QRect rect(iX, iY, iWidth, iHeight);
     
    705713        case KMachineState_TeleportingPausedVM:
    706714        {
    707             if (   m_pFrameBuffer
     715            if (   frameBuffer()
    708716                && (   state           != KMachineState_TeleportingPausedVM
    709717                    || m_previousState != KMachineState_Teleporting))
     
    741749                m_previousState == KMachineState_Restoring)
    742750            {
    743                 if (m_pFrameBuffer)
     751                if (frameBuffer())
    744752                {
    745753                    /* Reset pause-pixmap: */
     
    861869        /* Create new frame-buffer: */
    862870        m_pFrameBuffer = new UIFrameBuffer;
    863         m_pFrameBuffer->init(this);
     871        frameBuffer()->init(this);
    864872
    865873        /* Take scaling optimization type into account: */
    866         m_pFrameBuffer->setScalingOptimizationType(gEDataManager->scalingOptimizationType(uiCommon().managedVMUuid()));
     874        frameBuffer()->setScalingOptimizationType(gEDataManager->scalingOptimizationType(uiCommon().managedVMUuid()));
    867875
    868876        /* Acquire selected scale-factor: */
     
    876884
    877885        /* Assign frame-buffer with new values: */
    878         m_pFrameBuffer->setDevicePixelRatio(dDevicePixelRatioFormal);
    879         m_pFrameBuffer->setDevicePixelRatioActual(dDevicePixelRatioActual);
    880         m_pFrameBuffer->setScaleFactor(dScaleFactor);
    881         m_pFrameBuffer->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
     886        frameBuffer()->setDevicePixelRatio(dDevicePixelRatioFormal);
     887        frameBuffer()->setDevicePixelRatioActual(dDevicePixelRatioActual);
     888        frameBuffer()->setScaleFactor(dScaleFactor);
     889        frameBuffer()->setUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput);
    882890
    883891        /* Propagate the scale-factor related attributes to 3D service if necessary: */
     
    899907
    900908        /* Perform frame-buffer rescaling: */
    901         m_pFrameBuffer->performRescale();
     909        frameBuffer()->performRescale();
    902910
    903911        /* Associate uisession with frame-buffer finally: */
    904         uisession()->setFrameBuffer(screenId(), m_pFrameBuffer);
     912        uisession()->setFrameBuffer(screenId(), frameBuffer());
    905913    }
    906914
    907915    /* Make sure frame-buffer was prepared: */
    908     AssertReturnVoid(m_pFrameBuffer);
     916    AssertReturnVoid(frameBuffer());
    909917
    910918    /* Reattach to IDisplay: */
    911     m_pFrameBuffer->detach();
    912     m_pFrameBuffer->attach();
     919    frameBuffer()->detach();
     920    frameBuffer()->attach();
    913921
    914922    /* Calculate frame-buffer size: */
     
    10311039{
    10321040    /* Make sure framebuffer assigned at all: */
    1033     if (!m_pFrameBuffer)
     1041    if (!frameBuffer())
    10341042        return;
    10351043
    10361044    /* Make sure proper framebuffer assigned: */
    1037     AssertReturnVoid(m_pFrameBuffer == uisession()->frameBuffer(screenId()));
     1045    AssertReturnVoid(frameBuffer() == uisession()->frameBuffer(screenId()));
    10381046
    10391047    /* Mark framebuffer as unused: */
    10401048    LogRelFlow(("GUI: UIMachineView::cleanupFrameBuffer: Stop EMT callbacks accepting for screen: %d\n", screenId()));
    1041     m_pFrameBuffer->setMarkAsUnused(true);
     1049    frameBuffer()->setMarkAsUnused(true);
    10421050
    10431051    /* Process pending framebuffer events: */
     
    10491057     * to ensure 3D gets notified of view being destroyed... */
    10501058    if (console().isOk() && !display().isNull())
    1051         m_pFrameBuffer->detach();
     1059        frameBuffer()->detach();
    10521060
    10531061    /* Detach framebuffer from view: */
    1054     m_pFrameBuffer->setView(NULL);
     1062    frameBuffer()->setView(NULL);
    10551063}
    10561064
     
    11231131
    11241132    /* Get frame-buffer size-hint: */
    1125     QSize size(m_pFrameBuffer->width(), m_pFrameBuffer->height());
     1133    QSize size(frameBuffer()->width(), frameBuffer()->height());
    11261134
    11271135    /* Take the scale-factor(s) into account: */
     
    11521160int UIMachineView::contentsWidth() const
    11531161{
    1154     return m_pFrameBuffer->width();
     1162    return frameBuffer()->width();
    11551163}
    11561164
    11571165int UIMachineView::contentsHeight() const
    11581166{
    1159     return m_pFrameBuffer->height();
     1167    return frameBuffer()->height();
    11601168}
    11611169
     
    12881296{
    12891297    /* Prepare a screen-shot: */
    1290     QImage screenShot = QImage(m_pFrameBuffer->width(), m_pFrameBuffer->height(), QImage::Format_RGB32);
     1298    QImage screenShot = QImage(frameBuffer()->width(), frameBuffer()->height(), QImage::Format_RGB32);
    12911299    /* Which will be a 'black image' by default. */
    12921300    screenShot.fill(0);
     
    15111519
    15121520    /* Create the image ref out of the frame-buffer: */
    1513     return frameBuffertoCGImageRef(m_pFrameBuffer);
     1521    return frameBuffertoCGImageRef(frameBuffer());
    15141522}
    15151523
     
    15821590                /* Notify framebuffer about viewport resize: */
    15831591                QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
    1584                 if (m_pFrameBuffer)
    1585                     m_pFrameBuffer->viewportResized(pResizeEvent);
     1592                if (frameBuffer())
     1593                    frameBuffer()->viewportResized(pResizeEvent);
    15861594                /* Update console's display viewport and 3D overlay: */
    15871595                updateViewport();
     
    16961704
    16971705    /* Delegate the paint function to the UIFrameBuffer interface: */
    1698     if (m_pFrameBuffer)
    1699         m_pFrameBuffer->handlePaintEvent(pPaintEvent);
     1706    if (frameBuffer())
     1707        frameBuffer()->handlePaintEvent(pPaintEvent);
    17001708#ifdef VBOX_WS_MAC
    17011709    /* Update the dock icon if we are in the running state: */
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