VirtualBox

Changeset 107335 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Dec 16, 2024 5:38:41 PM (5 weeks ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10814: VBox Manager: Cleanup for Machine Manager widget's public getters, a bit of sanity checks and paranoia.

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

Legend:

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

    r107334 r107335  
    221221UIToolType UIMachineManagerWidget::menuToolType() const
    222222{
    223     return m_pMenuTools ? m_pMenuTools->toolsType() : UIToolType_Invalid;
     223    AssertPtrReturn(m_pMenuTools, UIToolType_Invalid);
     224    return m_pMenuTools->toolsType();
    224225}
    225226
    226227void UIMachineManagerWidget::setMenuToolType(UIToolType enmType)
    227228{
     229    /* Sanity check: */
     230    AssertReturnVoid(enmType != UIToolType_Invalid);
     231    /* Make sure new tool type is of Machine class: */
     232    AssertReturnVoid(UIToolStuff::isTypeOfClass(enmType, UIToolClass_Machine));
     233
     234    AssertPtrReturnVoid(m_pMenuTools);
    228235    m_pMenuTools->setToolsType(enmType);
    229236}
     
    231238UIToolType UIMachineManagerWidget::toolType() const
    232239{
    233     return m_pPaneTools ? m_pPaneTools->currentTool() : UIToolType_Invalid;
     240    AssertPtrReturn(m_pPaneTools, UIToolType_Invalid);
     241    return m_pPaneTools->currentTool();
    234242}
    235243
    236244bool UIMachineManagerWidget::isToolOpened(UIToolType enmType) const
    237245{
    238     return m_pPaneTools ? m_pPaneTools->isToolOpened(enmType) : false;
     246    /* Sanity check: */
     247    AssertReturn(enmType != UIToolType_Invalid, false);
     248    /* Make sure new tool type is of Machine class: */
     249    AssertReturn(UIToolStuff::isTypeOfClass(enmType, UIToolClass_Machine), false);
     250
     251    AssertPtrReturn(m_pPaneTools, false);
     252    return m_pPaneTools->isToolOpened(enmType);
    239253}
    240254
    241255void UIMachineManagerWidget::switchToolTo(UIToolType enmType)
    242256{
     257    /* Sanity check: */
     258    AssertReturnVoid(enmType != UIToolType_Invalid);
     259    /* Make sure new tool type is of Machine class: */
     260    AssertReturnVoid(UIToolStuff::isTypeOfClass(enmType, UIToolClass_Machine));
     261
    243262    /* Open corresponding tool: */
     263    AssertPtrReturnVoid(m_pPaneTools);
    244264    m_pPaneTools->openTool(enmType);
    245265
     
    250270void UIMachineManagerWidget::closeTool(UIToolType enmType)
    251271{
     272    /* Sanity check: */
     273    AssertReturnVoid(enmType != UIToolType_Invalid);
     274    /* Make sure new tool type is of Machine class: */
     275    AssertReturnVoid(UIToolStuff::isTypeOfClass(enmType, UIToolClass_Machine));
     276
     277    AssertPtrReturnVoid(m_pPaneTools);
    252278    m_pPaneTools->closeTool(enmType);
    253279}
     
    255281bool UIMachineManagerWidget::isCurrentStateItemSelected() const
    256282{
     283    AssertPtrReturn(m_pPaneTools, false);
    257284    return m_pPaneTools->isCurrentStateItemSelected();
    258285}
     
    260287QUuid UIMachineManagerWidget::currentSnapshotId()
    261288{
     289    AssertPtrReturn(m_pPaneTools, QUuid());
    262290    return m_pPaneTools->currentSnapshotId();
    263291}
     
    265293QString UIMachineManagerWidget::currentHelpKeyword() const
    266294{
    267     QString strHelpKeyword;
    268     if (isMachineItemSelected())
    269         strHelpKeyword = m_pPaneTools->currentHelpKeyword();
    270     return strHelpKeyword;
     295    AssertPtrReturn(m_pPaneTools, QString());
     296    return m_pPaneTools->currentHelpKeyword();
    271297}
    272298
     
    436462}
    437463
     464void UIMachineManagerWidget::sltHandleToolsMenuIndexChange(UIToolType enmType)
     465{
     466    switchToolTo(enmType);
     467}
     468
    438469void UIMachineManagerWidget::sltSwitchToVMActivityPane(const QUuid &uMachineId)
    439470{
     
    590621    }
    591622
    592     /* Open tools last chosen in Tools-menu: */
     623    /* Open tool last chosen in Tools-menu: */
    593624    switchToolTo(m_pMenuTools->toolsType());
    594625}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIMachineManagerWidget.h

    r107334 r107335  
    255255        /** Handles signal about Tools-menu index change.
    256256          * @param  enmType  Brings current tool type. */
    257         void sltHandleToolsMenuIndexChange(UIToolType enmType) { switchToolTo(enmType); }
     257        void sltHandleToolsMenuIndexChange(UIToolType enmType);
    258258
    259259        /** Switches to VM Activity pane of machine with @a uMachineId. */
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