[Bf-blender-cvs] [a742abf] HMD_viewport: Fix crash when stopping HMD session

Julian Eisel noreply at git.blender.org
Wed Apr 13 19:58:55 CEST 2016


Commit: a742abfafb229c5487d41950baef2388e32a9154
Author: Julian Eisel
Date:   Wed Apr 13 19:53:30 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rBa742abfafb229c5487d41950baef2388e32a9154

Fix crash when stopping HMD session

OpenHMD context should only be closed when deleting GHOST_OpenHMDManager, forgot to change that in rB0c029b7f86a0.

===================================================================

M	intern/ghost/intern/GHOST_OpenHMDManager.cpp
M	intern/ghost/intern/GHOST_OpenHMDManager.h

===================================================================

diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.cpp b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
index 90b69a9..2e5c32e 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.cpp
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
@@ -43,6 +43,7 @@ GHOST_OpenHMDManager::GHOST_OpenHMDManager(GHOST_System& sys)
 GHOST_OpenHMDManager::~GHOST_OpenHMDManager()
 {
 	closeDevice();
+	destroyContext();
 }
 
 bool GHOST_OpenHMDManager::processEvents()
@@ -159,7 +160,7 @@ bool GHOST_OpenHMDManager::openDevice(int index)
 
 	// Blender only allows one opened device at a time
 	if (getOpenHMDDevice()) {
-	closeDevice();
+		closeDevice();
 	}
 
 	// can't fail to open the device
@@ -174,7 +175,6 @@ void GHOST_OpenHMDManager::closeDevice()
 		return;
 	}
 
-	destroyContext();
 	m_device = NULL;
 	m_deviceIndex = -1;
 }
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.h b/intern/ghost/intern/GHOST_OpenHMDManager.h
index db6cfdc..691ba3a 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.h
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.h
@@ -286,13 +286,14 @@ protected:
 
 private:
 
-	/** 
-	 * 	Create the context if it hasn't been created yet
-	 * 	\return True if a context was created or was already available.
+	/**
+	 * Create the context if it hasn't been created yet.
+	 * The context lives as long as the #GHOST_OpenHMDManager lives.
+	 * \return True if a context was created or was already available.
 	 */
 	bool createContext();
 	/**
-	 * Destroy and NULL #m_context.
+	 * Destroy and NULL #m_context. Should only be done when deleting #GHOST_OpenHMDManager.
 	 */
 	void destroyContext();




More information about the Bf-blender-cvs mailing list