VirtualBox

Changeset 102419 in vbox


Ignore:
Timestamp:
Dec 1, 2023 1:30:48 PM (17 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160562
Message:

FE/Qt: bugref:10450: Runtime UI: Make sure close-event is accepted when necessary as Qt6 always requires this opposing to Qt5.

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

Legend:

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

    r102018 r102419  
    11211121    /* Asynchronously ask QApplication to quit: */
    11221122    LogRel(("GUI: Request for async QApp quit.\n"));
     1123    m_fQuitRequested = true;
    11231124    QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection);
    11241125}
     
    14711472    , m_defaultCloseAction(MachineCloseAction_Invalid)
    14721473    , m_restrictedCloseActions(MachineCloseAction_Invalid)
     1474    , m_fQuitRequested(false)
    14731475{
    14741476    s_pInstance = this;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r102018 r102419  
    680680        bool acquireWhetherGuestEnteredACPIMode(bool &fEntered);
    681681
     682        /** Returns whether qpp quit is requested. */
     683        bool isQuitRequested() const { return m_fQuitRequested; }
     684
    682685        /** Detaches and closes Runtime UI. */
    683686        void detachUi();
     
    11071110        /** Merged restricted close actions. */
    11081111        MachineCloseAction  m_restrictedCloseActions;
     1112
     1113        /** Holds whether app quit is requested. */
     1114        bool  m_fQuitRequested;
    11091115    /** @} */
    11101116};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r100153 r102419  
    360360void UIMachineWindow::closeEvent(QCloseEvent *pCloseEvent)
    361361{
    362     /* Fast handling in case if session is invalid: */
    363     if (!uimachine()->isSessionValid())
     362    /* Always ignore close-event first: */
     363    pCloseEvent->ignore();
     364    /* But accept close-event if app quit was requested: */
     365    if (uimachine()->isQuitRequested())
     366    {
     367        pCloseEvent->accept();
     368        return;
     369    }
     370
     371    /* In certain cases we need to just request app quit: */
     372    if (   !uimachine()->isSessionValid()
     373        || uimachine()->isTurnedOff())
    364374    {
    365375        uimachine()->closeRuntimeUI();
     
    367377    }
    368378
    369     /* Always ignore close-event first: */
    370     pCloseEvent->ignore();
    371 
    372379    /* Make sure machine is in one of the allowed states: */
    373380    if (!uimachine()->isRunning() && !uimachine()->isPaused() && !uimachine()->isStuck())
    374     {
    375 #ifdef VBOX_IS_QT6_OR_LATER /** @todo qt6 ... */
    376         /* If we want to close the application, we need to accept the close event.
    377            If we don't the QEvent::Quit processing in QApplication::event fails and
    378            [QCocoaApplicationDelegate applicationShouldTerminate] complains printing
    379            "Qt DEBUG: Application termination canceled" in the debug log. */
    380         /** @todo qt6: This could easily be caused by something else, but needs to be
    381          * looked at by a proper GUI expert.  */
    382         if (uimachine()->isTurnedOff()) /** @todo qt6: Better state check here? */
    383             pCloseEvent->accept();
    384 #endif
    385381        return;
    386     }
    387382
    388383    /* If there is a close hook script defined: */
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