From 64922ff47133caca2a7a3d38ebfecc4ba8754fe3 Mon Sep 17 00:00:00 2001
From: Ehret <jw210150@WIN.RZ.RWTH-AACHEN.DE>
Date: Wed, 8 Sep 2021 10:21:54 +0200
Subject: [PATCH] fix loading/getting of cluster manager if DisplayCluster
 module was not loaded yet

---
 Source/Calibratio/Private/Calibratio.cpp                | 6 +++---
 Source/RWTHVRToolkit/Private/Cluster/ClusterConsole.cpp | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Source/Calibratio/Private/Calibratio.cpp b/Source/Calibratio/Private/Calibratio.cpp
index a3a085b2..53683947 100644
--- a/Source/Calibratio/Private/Calibratio.cpp
+++ b/Source/Calibratio/Private/Calibratio.cpp
@@ -25,8 +25,8 @@ void FCalibratioModule::StartupModule ()
 
 	
 	/* Register cluster event listening */
-	IDisplayClusterClusterManager* ClusterManager = IDisplayCluster::Get().GetClusterMgr();
-	if (ClusterManager && !ClusterEventListenerDelegate.IsBound())
+	IDisplayCluster* DisplayCluster = FModuleManager::LoadModulePtr<IDisplayCluster>(IDisplayCluster::ModuleName);
+	if (DisplayCluster && !ClusterEventListenerDelegate.IsBound())
 	{
 		ClusterEventListenerDelegate = FOnClusterEventJsonListener::CreateLambda([](const FDisplayClusterClusterEventJson& Event)
 		{
@@ -35,7 +35,7 @@ void FCalibratioModule::StartupModule ()
 				SpawnCalibratio();
 			}
 		});
-		ClusterManager->AddClusterEventJsonListener(ClusterEventListenerDelegate);
+		DisplayCluster->GetClusterMgr()->AddClusterEventJsonListener(ClusterEventListenerDelegate);
 	}
 }
 void FCalibratioModule::ShutdownModule()
diff --git a/Source/RWTHVRToolkit/Private/Cluster/ClusterConsole.cpp b/Source/RWTHVRToolkit/Private/Cluster/ClusterConsole.cpp
index 966f4f01..55a3ad97 100644
--- a/Source/RWTHVRToolkit/Private/Cluster/ClusterConsole.cpp
+++ b/Source/RWTHVRToolkit/Private/Cluster/ClusterConsole.cpp
@@ -21,8 +21,8 @@ void FClusterConsole::Register()
 	}));
 
 	/* Register cluster event handling */
-	IDisplayClusterClusterManager* ClusterManager = IDisplayCluster::Get().GetClusterMgr();
-	if (ClusterManager && !ClusterEventListenerDelegate.IsBound())
+	IDisplayCluster* DisplayCluster = FModuleManager::LoadModulePtr<IDisplayCluster>(IDisplayCluster::ModuleName);
+	if (DisplayCluster && !ClusterEventListenerDelegate.IsBound())
 	{
 		ClusterEventListenerDelegate = FOnClusterEventJsonListener::CreateLambda([](const FDisplayClusterClusterEventJson& Event)
 		{		
@@ -32,7 +32,7 @@ void FClusterConsole::Register()
 				GEngine->Exec(GEngine->GetCurrentPlayWorld(), *Event.Parameters["Command"]);
 			}
 		});
-		ClusterManager->AddClusterEventJsonListener(ClusterEventListenerDelegate);
+		DisplayCluster->GetClusterMgr()->AddClusterEventJsonListener(ClusterEventListenerDelegate);
 	}
 }
 
-- 
GitLab