Skip to content

Commit 2192cc4

Browse files
authored
Merge pull request #296 from Ziugy/dev/crashFixDirectPairing
Fix DirectPairing from crashing the editor and application
2 parents fc627cf + 5d9c6f0 commit 2192cc4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Assets/HoloToolkit/Sharing/Scripts/Utilities/DirectPairing.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ void Start()
6363

6464
void OnDestroy()
6565
{
66-
if (this.sharingMgr != null)
66+
// SharingStage's OnDestroy() might execute first in the script order. Therefore we should check if
67+
// SharingStage.Instance still exists. Without the instance check, the execution of GetPairingManager
68+
// on a disposed sharing manager will crash the Unity Editor and application.
69+
if (SharingStage.Instance != null && this.sharingMgr != null)
6770
{
6871
PairingManager pairingMgr = sharingMgr.GetPairingManager();
6972
pairingMgr.CancelPairing(); // Safe to call, even if no pairing is in progress. Will not cause a disconnect

0 commit comments

Comments
 (0)