VirtualBox

Changeset 98841 in vbox for trunk


Ignore:
Timestamp:
Mar 6, 2023 3:21:32 PM (19 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking UIFrameBuffer stuff so that it is fully created inside UISession, not UIMachineView; Potentially dangerous.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
8 edited

Legend:

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

    r98839 r98841  
    23182318
    23192319UIFrameBuffer::UIFrameBuffer()
     2320    : m_fInitialized(false)
    23202321{
    23212322    prepare();
     
    23292330HRESULT UIFrameBuffer::init(UIMachineView *pMachineView)
    23302331{
    2331     return m_pFrameBuffer->init(pMachineView);
     2332    const HRESULT rc = m_pFrameBuffer->init(pMachineView);
     2333    m_fInitialized = true;
     2334    return rc;
    23322335}
    23332336
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.h

    r98838 r98841  
    6363      * @param pMachineView defines machine-view this frame-buffer is bounded to. */
    6464    HRESULT init(UIMachineView *pMachineView);
     65    /** Returns whether frame-buffer was initialized already. */
     66    bool isInitialized() const { return m_fInitialized; }
    6567
    6668    /** Assigns machine-view frame-buffer will be bounded to.
     
    147149    /** Holds the frame-buffer private instance. */
    148150    ComObjPtr<UIFrameBufferPrivate> m_pFrameBuffer;
     151
     152    /** Holds whether frame-buffer was initialized already. */
     153    bool  m_fInitialized;
    149154};
    150155
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98830 r98841  
    198198    /* Destroy machine UI: */
    199199    delete pInstance;
     200}
     201
     202UIFrameBuffer *UIMachine::frameBuffer(ulong uScreenId)
     203{
     204    return uisession()->frameBuffer(uScreenId);
    200205}
    201206
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98840 r98841  
    5050class QWidget;
    5151class UIActionPool;
     52class UIFrameBuffer;
    5253class UIMachineLogic;
    5354class UISession;
     
    170171    /** Returns machine-logic instance. */
    171172    UIMachineLogic *machineLogic() const { return m_pMachineLogic; }
     173    /** Returns frame-buffer reference for screen with @a uScreenId specified. */
     174    UIFrameBuffer *frameBuffer(ulong uScreenId);
    172175    /** Returns active machine-window reference (if possible). */
    173176    QWidget* activeWindow() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r98840 r98841  
    4141#include "UIMachine.h"
    4242#include "UIMessageCenter.h"
    43 #include "UISession.h"
    4443#include "UIMachineLogic.h"
    4544#include "UIMachineWindow.h"
     
    267266}
    268267
    269 UISession *UIMachineView::uisession() const
    270 {
    271     return uimachine()->uisession();
    272 }
    273 
    274268UIMachineLogic *UIMachineView::machineLogic() const
    275269{
    276270    return machineWindow()->machineLogic();
     271}
     272
     273UIFrameBuffer *UIMachineView::frameBuffer() const
     274{
     275    return uimachine()->frameBuffer(m_uScreenId);
    277276}
    278277
     
    11531152    , m_pMachineWindow(pMachineWindow)
    11541153    , m_uScreenId(uScreenId)
    1155     , m_pFrameBuffer(0)
    11561154    , m_previousState(KMachineState_Null)
    11571155    , m_iHostScreenNumber(0)
     
    11911189void UIMachineView::prepareFrameBuffer()
    11921190{
    1193     /* Check whether we already have corresponding frame-buffer: */
    1194     UIFrameBuffer *pFrameBuffer = uisession()->frameBuffer(screenId());
    1195 
    1196     /* If we do not: */
    1197     if (!pFrameBuffer)
     1191    /* If frame-buffer NOT yet initialized: */
     1192    if (!frameBuffer()->isInitialized())
    11981193    {
    11991194        LogRelFlow(("GUI: UIMachineView::prepareFrameBuffer: Start EMT callbacks accepting for screen: %d\n", screenId()));
    1200         /* Create new frame-buffer: */
    1201         m_pFrameBuffer = new UIFrameBuffer;
    1202         /* Init it's view: */
    1203         m_pFrameBuffer->init(this);
     1195        /* Initialize for this view: */
     1196        frameBuffer()->init(this);
    12041197        /* Apply machine-view scale-factor: */
    12051198        applyMachineViewScaleFactor();
    1206         /* Associate uisession with frame-buffer finally: */
    1207         uisession()->setFrameBuffer(screenId(), frameBuffer());
    1208     }
    1209     /* If we do: */
     1199    }
     1200    /* Otherwise it must be unused yet: */
    12101201    else
    12111202    {
    12121203        LogRelFlow(("GUI: UIMachineView::prepareFrameBuffer: Restart EMT callbacks accepting for screen: %d\n", screenId()));
    12131204        /* Assign it's view: */
    1214         pFrameBuffer->setView(this);
     1205        frameBuffer()->setView(this);
    12151206        /* Mark frame-buffer as used again: */
    1216         pFrameBuffer->setMarkAsUnused(false);
    1217         /* And remember our choice: */
    1218         m_pFrameBuffer = pFrameBuffer;
     1207        frameBuffer()->setMarkAsUnused(false);
    12191208    }
    12201209
     
    13721361    if (!frameBuffer())
    13731362        return;
    1374 
    1375     /* Make sure proper framebuffer assigned: */
    1376     AssertReturnVoid(frameBuffer() == uisession()->frameBuffer(screenId()));
    13771363
    13781364    /* Mark framebuffer as unused: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r98700 r98841  
    3535#include <QAbstractScrollArea>
    3636#include <QEventLoop>
    37 #include <QPointer>
    3837
    3938/* GUI includes: */
     
    6564class UIMachineWindow;
    6665class UINativeEventFilter;
    67 class UISession;
    6866class CGuest;
    6967class CSession;
     
    112110    /** Returns the machine UI reference. */
    113111    UIMachine *uimachine() const;
    114     /** Returns the session UI reference. */
    115     UISession *uisession() const;
    116112    /** Returns the machine-logic reference. */
    117113    UIMachineLogic *machineLogic() const;
     
    119115    UIMachineWindow *machineWindow() const { return m_pMachineWindow; }
    120116    /** Returns view's frame-buffer reference. */
    121     UIFrameBuffer *frameBuffer() const { return m_pFrameBuffer; }
     117    UIFrameBuffer *frameBuffer() const;
    122118
    123119    /** Returns actual contents width. */
     
    387383    UIMachineWindow *m_pMachineWindow;
    388384    ulong m_uScreenId;
    389     QPointer<UIFrameBuffer> m_pFrameBuffer;
    390385    KMachineState m_previousState;
    391386    /** HACK: when switching out of fullscreen or seamless we wish to override
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98840 r98841  
    14131413{
    14141414    return m_frameBufferVector.value((int)uScreenId, 0);
    1415 }
    1416 
    1417 void UISession::setFrameBuffer(ulong uScreenId, UIFrameBuffer *pFrameBuffer)
    1418 {
    1419     Assert(uScreenId < (ulong)m_frameBufferVector.size());
    1420     if (uScreenId < (ulong)m_frameBufferVector.size())
    1421         m_frameBufferVector[(int)uScreenId] = pFrameBuffer;
    14221415}
    14231416
     
    25002493    acquireMonitorCount(cGuestScreenCount);
    25012494    m_frameBufferVector.resize(cGuestScreenCount);
     2495
     2496    /* Create new frame-buffers: */
     2497    for (int iIndex = 0; iIndex < m_frameBufferVector.size(); ++iIndex)
     2498        m_frameBufferVector[iIndex] = new UIFrameBuffer;
    25022499}
    25032500
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98830 r98841  
    425425          * @returns 0 (asserts) if uScreenId attribute is out of bounds. */
    426426        UIFrameBuffer *frameBuffer(ulong uScreenId) const;
    427         /** Sets framebuffer for the screen with given @a uScreenId;
    428           * Ignores (asserts) if screen-number attribute is out of bounds. */
    429         void setFrameBuffer(ulong uScreenId, UIFrameBuffer *pFrameBuffer);
    430427        /** Returns existing frame-buffer vector. */
    431428        const QVector<UIFrameBuffer*> &frameBuffers() const { return m_frameBufferVector; }
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