summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2022-11-18 10:25:20 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2022-11-18 10:25:20 +0000
commit3bfd9c8eaba6949d07cbd8888ab7c303cee810b0 (patch)
treeef4212b989790e1b918f3f556405a92d410899b2
parent0e927ac4435321404584ca8876a200658883780f (diff)
downloadVirtualBox-svn-3bfd9c8eaba6949d07cbd8888ab7c303cee810b0.tar.gz
FE/Qt: bugref:10276: !VirtualBox Manager: Re-register VM if groups have changed from outside.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@97605 cfe28804-0f27-0410-a406-dd0f0b0b656f
-rw-r--r--src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp32
-rw-r--r--src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h2
2 files changed, 34 insertions, 0 deletions
diff --git a/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp b/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
index 1ae2420484a..fab4499da90 100644
--- a/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
@@ -728,6 +728,36 @@ void UIChooserAbstractModel::sltLocalMachineRegistrationChanged(const QUuid &uMa
}
}
+void UIChooserAbstractModel::sltLocalMachineGroupsChanged(const QUuid &uMachineId)
+{
+ /* Skip VM if restricted: */
+ if (!gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
+ return;
+
+ /* Search for cached group list: */
+ const QStringList oldGroupList = m_groups.value(toOldStyleUuid(uMachineId));
+ //printf("Old groups for VM with ID=%s: %s\n",
+ // uMachineId.toString().toUtf8().constData(),
+ // oldGroupList.join(", ").toUtf8().constData());
+
+ /* Search for existing registered machine: */
+ const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
+ if (comMachine.isNull())
+ return;
+ /* Look for a new group list: */
+ const QStringList newGroupList = comMachine.GetGroups().toList();
+ //printf("New groups for VM with ID=%s: %s\n",
+ // uMachineId.toString().toUtf8().constData(),
+ // newGroupList.join(", ").toUtf8().constData());
+
+ /* Re-register VM if required: */
+ if (newGroupList.toSet() != oldGroupList.toSet())
+ {
+ sltLocalMachineRegistrationChanged(uMachineId, false);
+ sltLocalMachineRegistrationChanged(uMachineId, true);
+ }
+}
+
void UIChooserAbstractModel::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState)
{
/* Update machine-nodes with passed id: */
@@ -1015,6 +1045,8 @@ void UIChooserAbstractModel::prepareConnections()
this, &UIChooserAbstractModel::sltLocalMachineDataChanged);
connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineRegistered,
this, &UIChooserAbstractModel::sltLocalMachineRegistrationChanged);
+ connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineGroupsChange,
+ this, &UIChooserAbstractModel::sltLocalMachineGroupsChanged);
connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
this, &UIChooserAbstractModel::sltSessionStateChanged);
connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotTake,
diff --git a/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h b/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
index 1a3a63a2045..584a20653e4 100644
--- a/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
+++ b/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
@@ -181,6 +181,8 @@ protected slots:
virtual void sltLocalMachineDataChanged(const QUuid &uMachineId);
/** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
virtual void sltLocalMachineRegistrationChanged(const QUuid &uMachineId, const bool fRegistered);
+ /** Handles local machine registering/unregistering for machine with certain @a uMachineId. */
+ virtual void sltLocalMachineGroupsChanged(const QUuid &uMachineId);
/** Handles session @a enmState change for machine with certain @a uMachineId. */
virtual void sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmState);