[Bf-blender-cvs] [7e4a96f0ab2] HMD_viewport: Fixes for Windows compile, fixes crashes when trying to open locked devices

Joey Ferwerda noreply at git.blender.org
Sat Apr 1 13:03:34 CEST 2017


Commit: 7e4a96f0ab2ee24ea5fd19ff2394f2c2e68ed406
Author: Joey Ferwerda
Date:   Sat Apr 1 12:59:29 2017 +0200
Branches: HMD_viewport
https://developer.blender.org/rB7e4a96f0ab2ee24ea5fd19ff2394f2c2e68ed406

Fixes for Windows compile, fixes crashes when trying to open locked devices

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

M	extern/openhmd/src/drv_oculus_rift/rift.c
M	intern/ghost/intern/GHOST_OpenHMDManager.cpp

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

diff --git a/extern/openhmd/src/drv_oculus_rift/rift.c b/extern/openhmd/src/drv_oculus_rift/rift.c
index bc4bddac5d2..a481719d56f 100644
--- a/extern/openhmd/src/drv_oculus_rift/rift.c
+++ b/extern/openhmd/src/drv_oculus_rift/rift.c
@@ -210,6 +210,7 @@ static void close_device(ohmd_device* device)
 	free(priv);
 }
 
+#ifndef _MSC_VER
 static char* _hid_to_unix_path(char* path)
 {
 	char bus [4];
@@ -224,6 +225,12 @@ static char* _hid_to_unix_path(char* path)
 		(int)strtol(dev, NULL, 16));
 	return result;
 }
+#else
+static char* _hid_to_unix_path(char* path)
+{
+	return path;
+}
+#endif
 
 static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
 {
@@ -244,7 +251,9 @@ static ohmd_device* open_device(ohmd_driver* driver, ohmd_device_desc* desc)
 		char* path = _hid_to_unix_path(desc->path);
 		ohmd_set_error(driver->ctx, "Could not open %s. "
 		                            "Check your rights.", path);
+		#ifndef _MSC_VER
 		free(path);
+		#endif
 		goto cleanup;
 	}
 
diff --git a/intern/ghost/intern/GHOST_OpenHMDManager.cpp b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
index 03c25a96a6a..7a93851c369 100644
--- a/intern/ghost/intern/GHOST_OpenHMDManager.cpp
+++ b/intern/ghost/intern/GHOST_OpenHMDManager.cpp
@@ -179,6 +179,11 @@ bool GHOST_OpenHMDManager::openDevice(int index)
 	m_device = ohmd_list_open_device_s(m_context, index, settings);
 	ohmd_device_settings_destroy(settings); //cleanup settings
 
+	if (!m_device) {
+		printf("Could not open device, please check your rights\n");
+		return false;
+	}
+
 	m_projection_params = new OpenHMDDistortionParameters;
 	// Set the thing for the stuff
 	ohmd_device_getf(m_device, OHMD_SCREEN_HORIZONTAL_SIZE, &(m_projection_params->viewport_scale[0]));




More information about the Bf-blender-cvs mailing list