VirtualBox

Changeset 97605 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 18, 2022 10:25:20 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154649
Message:

FE/Qt: bugref:10276: VirtualBox Manager: Re-register VM if groups have changed from outside.

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

Legend:

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

    r96407 r97605  
    726726                addLocalMachineIntoTheTree(comMachine, true /* make it visible */);
    727727        }
     728    }
     729}
     730
     731void UIChooserAbstractModel::sltLocalMachineGroupsChanged(const QUuid &uMachineId)
     732{
     733    /* Skip VM if restricted: */
     734    if (!gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
     735        return;
     736
     737    /* Search for cached group list: */
     738    const QStringList oldGroupList = m_groups.value(toOldStyleUuid(uMachineId));
     739    //printf("Old groups for VM with ID=%s: %s\n",
     740    //       uMachineId.toString().toUtf8().constData(),
     741    //       oldGroupList.join(", ").toUtf8().constData());
     742
     743    /* Search for existing registered machine: */
     744    const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
     745    if (comMachine.isNull())
     746        return;
     747    /* Look for a new group list: */
     748    const QStringList newGroupList = comMachine.GetGroups().toList();
     749    //printf("New groups for VM with ID=%s: %s\n",
     750    //       uMachineId.toString().toUtf8().constData(),
     751    //       newGroupList.join(", ").toUtf8().constData());
     752
     753    /* Re-register VM if required: */
     754    if (newGroupList.toSet() != oldGroupList.toSet())
     755    {
     756        sltLocalMachineRegistrationChanged(uMachineId, false);
     757        sltLocalMachineRegistrationChanged(uMachineId, true);
    728758    }
    729759}
     
    10161046    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineRegistered,
    10171047            this, &UIChooserAbstractModel::sltLocalMachineRegistrationChanged);
     1048    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineGroupsChange,
     1049            this, &UIChooserAbstractModel::sltLocalMachineGroupsChanged);
    10181050    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
    10191051            this, &UIChooserAbstractModel::sltSessionStateChanged);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r96407 r97605  
    182182        /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
    183183        virtual void sltLocalMachineRegistrationChanged(const QUuid &uMachineId, const bool fRegistered);
     184        /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
     185        virtual void sltLocalMachineGroupsChanged(const QUuid &uMachineId);
    184186
    185187        /** Handles session @a enmState change for machine with certain @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