VirtualBox

Changeset 83854 in vbox


Ignore:
Timestamp:
Apr 20, 2020 1:01:12 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137383
Message:

FE/Qt: bugref:9653: VirtualBox Manager: More careful guard block for actions which open some dialog preventing cascade opening and updating actions appropriately.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r83768 r83854  
    3333#include "UIMessageCenter.h"
    3434#include "UIModalWindowManager.h"
     35#include "UIQObjectStuff.h"
     36#include "UISettingsDialogSpecific.h"
    3537#include "UIVirtualBoxManager.h"
    3638#include "UIVirtualBoxManagerWidget.h"
    37 #include "UISettingsDialogSpecific.h"
    38 #include "UIVMLogViewerDialog.h"
    3939#include "UIVirtualMachineItemCloud.h"
    4040#include "UIVirtualMachineItemLocal.h"
    41 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    42 # include "UIUpdateManager.h"
    43 #endif
     41#include "UIVMLogViewerDialog.h"
    4442#include "UIVirtualBoxEventHandler.h"
    4543#include "UIWizardCloneVM.h"
     
    4745#include "UIWizardImportApp.h"
    4846#include "UIWizardNewCloudVM.h"
     47#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     48# include "UIUpdateManager.h"
     49#endif
    4950#ifdef VBOX_WS_MAC
    5051# include "UIImageTools.h"
    5152# include "UIWindowMenuManager.h"
    5253# include "VBoxUtils.h"
     54#else
     55# include "UIMenuBar.h"
    5356#endif
    5457#ifdef VBOX_WS_X11
    5558# include "UIDesktopWidgetWatchdog.h"
    56 #endif
    57 #ifndef VBOX_WS_MAC
    58 # include "UIMenuBar.h"
    5959#endif
    6060
     
    463463
    464464    /* Lock the action preventing cascade calls: */
    465     actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance)->setProperty("opened", true);
     465    UIQObjectPropertySetter guardBlock(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance), "opened", true);
     466    connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
     467    this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
    466468    updateActionsAppearance();
    467469
     
    474476        pWizard->exec();
    475477    delete pWizard;
    476 
    477     /* Unlock the action allowing further calls: */
    478     if (actionPool())
    479     {
    480         actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance)->setProperty("opened", QVariant());
    481         updateActionsAppearance();
    482     }
    483478}
    484479
     
    493488        names << items.at(i)->name();
    494489
    495     /* Lock the action preventing cascade calls: */
    496     actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)->setProperty("opened", true);
    497     actionPool()->action(UIActionIndexST_M_Machine_S_ExportToOCI)->setProperty("opened", true);
     490    /* Lock the actions preventing cascade calls: */
     491    UIQObjectPropertySetter guardBlock(QList<QObject*>() << actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)
     492                                                         << actionPool()->action(UIActionIndexST_M_Machine_S_ExportToOCI),
     493                                       "opened", true);
     494    connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
     495            this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
    498496    updateActionsAppearance();
    499497
     
    510508    pWizard->exec();
    511509    delete pWizard;
    512 
    513     /* Unlock the action allowing further calls: */
    514     if (actionPool())
    515     {
    516         actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)->setProperty("opened", QVariant());
    517         actionPool()->action(UIActionIndexST_M_Machine_S_ExportToOCI)->setProperty("opened", QVariant());
    518         updateActionsAppearance();
    519     }
    520510}
    521511
     
    523513{
    524514    /* Lock the action preventing cascade calls: */
    525     actionPool()->action(UIActionIndexST_M_File_S_NewCloudVM)->setProperty("opened", true);
     515    UIQObjectPropertySetter guardBlock(actionPool()->action(UIActionIndexST_M_File_S_NewCloudVM), "opened", true);
     516    connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
     517            this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
    526518    updateActionsAppearance();
    527519
     
    533525    pWizard->exec();
    534526    delete pWizard;
    535 
    536     /* Unlock the action allowing further calls: */
    537     if (actionPool())
    538     {
    539         actionPool()->action(UIActionIndexST_M_File_S_NewCloudVM)->setProperty("opened", QVariant());
    540         updateActionsAppearance();
    541     }
    542527}
    543528
     
    556541
    557542    /* Lock the action preventing cascade calls: */
    558     actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setProperty("opened", true);
     543    UIQObjectPropertySetter guardBlock(actionPool()->action(UIActionIndex_M_Application_S_Preferences), "opened", true);
     544    connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
     545            this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
    559546    updateActionsAppearance();
    560547
     
    563550    pDlg->execute();
    564551    delete pDlg;
    565 
    566     /* Unlock the action allowing further calls: */
    567     if (actionPool())
    568     {
    569         actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setProperty("opened", QVariant());
    570         updateActionsAppearance();
    571     }
    572552}
    573553
     
    587567    CVirtualBox comVBox = uiCommon().virtualBox();
    588568
    589     /* Lock the action preventing cascade calls: */
    590     actionPool()->action(UIActionIndexST_M_Welcome_S_Add)->setProperty("opened", true);
     569    /* Lock the actions preventing cascade calls: */
     570    UIQObjectPropertySetter guardBlock(QList<QObject*>() << actionPool()->action(UIActionIndexST_M_Welcome_S_Add)
     571                                                         << actionPool()->action(UIActionIndexST_M_Machine_S_Add)
     572                                                         << actionPool()->action(UIActionIndexST_M_Group_S_Add),
     573                                       "opened", true);
     574    connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
     575            this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
    591576    updateActionsAppearance();
    592577
     
    606591    }
    607592
    608     /* Unlock the action allowing further calls: */
    609     if (actionPool())
    610     {
    611         actionPool()->action(UIActionIndexST_M_Welcome_S_Add)->setProperty("opened", QVariant());
    612         updateActionsAppearance();
    613     }
    614 
    615593    /* Nothing was chosen? */
    616594    if (strTmpFile.isEmpty())
     
    646624
    647625    /* Lock the action preventing cascade calls: */
    648     actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setProperty("opened", true);
     626    UIQObjectPropertySetter guardBlock(actionPool()->action(UIActionIndexST_M_Machine_S_Settings), "opened", true);
     627    connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
     628            this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
    649629    updateActionsAppearance();
    650630
     
    677657        pDlg->execute();
    678658        delete pDlg;
    679     }
    680 
    681     /* Unlock the action allowing further calls: */
    682     if (actionPool())
    683     {
    684         actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setProperty("opened", QVariant());
    685         updateActionsAppearance();
    686659    }
    687660}
     
    19181891bool UIVirtualBoxManager::isActionEnabled(int iActionIndex, const QList<UIVirtualMachineItem*> &items)
    19191892{
     1893    /* Make sure action pool exists: */
     1894    AssertPtrReturn(actionPool(), false);
     1895
     1896    /* Any "opened" action is by definition disabled: */
     1897    if (   actionPool()->action(iActionIndex)
     1898        && actionPool()->action(iActionIndex)->property("opened").toBool())
     1899        return false;
     1900
    19201901    /* For known *global* action types: */
    19211902    switch (iActionIndex)
     
    19261907        case UIActionIndexST_M_File_S_NewCloudVM:
    19271908        case UIActionIndexST_M_Welcome_S_Add:
    1928         {
    1929             return !actionPool()->action(iActionIndex)->property("opened").toBool();
    1930         }
     1909            return true;
    19311910        default:
    19321911            break;
     
    19711950        case UIActionIndexST_M_Machine_S_Settings:
    19721951        {
    1973             return !actionPool()->action(iActionIndex)->property("opened").toBool() &&
    1974                    !isGroupSavingInProgress() &&
     1952            return !isGroupSavingInProgress() &&
    19751953                   items.size() == 1 &&
    19761954                   pItem->toLocal() &&
     
    19891967        case UIActionIndexST_M_Machine_S_ExportToOCI:
    19901968        {
    1991             return !actionPool()->action(iActionIndex)->property("opened").toBool() &&
    1992                    items.size() == 1 &&
     1969            return items.size() == 1 &&
    19931970                   pItem->toLocal();
    19941971        }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r83674 r83854  
    113113        void sltHandleHostScreenAvailableAreaChange();
    114114#endif /* VBOX_WS_X11 */
     115
     116        /** Handles request to update actions. */
     117        void sltHandleUpdateActionAppearanceRequest() { updateActionsAppearance(); }
    115118
    116119        /** Handles signal about medium-enumeration finished. */
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