Commits

Temp...@jmmdesk4  committed d2c7ea7

fix for issue #31 (pygame.error: No available video device)

  • Participants
  • Parent commits bf4bafb

Comments (0)

Files changed (1)

File lib/__init__.py

         # 3 (VER_PLATFORM_WIN32_CE)        Windows CE
         if sys.getwindowsversion()[0] == 1:
 
-            # To interpret DirectX version numbers, see this page:
-            # http://en.wikipedia.org/wiki/DirectX#Releases
+            import _winreg
+
             try:
 
-                import _winreg
-
                 # Get DirectX version from registry
                 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
                                       'SOFTWARE\\Microsoft\\DirectX')
                 dx_version_string = _winreg.QueryValueEx(key, 'Version')
-                minor_dx_version = int(dx_version_string.split('.')[1])
+                key.Close()
 
                 # Set video driver to directx if DirectX 5 or better is 
                 # installed.
+                # To interpret DirectX version numbers, see this page:
+                # http://en.wikipedia.org/wiki/DirectX#Releases
+                minor_dx_version = int(dx_version_string.split('.')[1])
                 if minor_dx_version >= 5:
                     os.environ['SDL_VIDEODRIVER'] = 'directx'
 
                 # Clean up namespace
-                del _winreg, key, dx_version_string, minor_dx_version
+                del key, dx_version_string, minor_dx_version
 
             except:
                 pass
 
+            # Clean up namespace
+            del _winreg
+
 # when running under X11, always set the SDL window WM_CLASS to make the
 #   window managers correctly match the pygame window.
 elif 'DISPLAY' in os.environ and not 'SDL_VIDEO_X11_WMCLASS' in os.environ: