@@ -49,6 +49,8 @@ def which(self, executable, paths=None):
4949from DisplayCAL .options import test_input_curve_clipping
5050from DisplayCAL .util_list import intlist
5151
52+ mscms_present = None
53+ mscms = None
5254
5355if sys .platform not in ("darwin" , "win32" ):
5456 from DisplayCAL .defaultpaths import xdg_config_dirs , xdg_config_home
@@ -60,28 +62,36 @@ def which(self, executable, paths=None):
6062 except ImportError :
6163 xrandr = None
6264 from DisplayCAL .util_os import dlopen , which
63- mscms = None
65+
66+ def get_mscms ():
67+ return mscms
6468elif sys .platform == "win32" :
6569 from DisplayCAL import util_win
6670 from DisplayCAL .mscms import WCSManager
6771
6872 if sys .getwindowsversion () < (6 ,):
6973 # WCS only available under Vista and later
70- mscms = None
74+ pass
7175 else :
7276 from DisplayCAL .win_handles import (
7377 get_process_handles ,
7478 get_handle_name ,
7579 get_handle_type ,
7680 )
7781
78- mscms = WCSManager ()
82+ mscms_present = True
7983
8084 win_ver = util_win .win_ver ()
8185 win10_1903 = (
8286 win_ver [0 ].startswith ("Windows 10" ) and win_ver [2 ] >= "Version 1903"
8387 )
8488
89+ def get_mscms ():
90+ global mscms
91+ if mscms is None :
92+ mscms = WCSManager ()
93+ return mscms
94+
8595# Gamut volumes in cubic colorspace units (L*a*b*) as reported by Argyll's
8696# iccgamut
8797GAMUT_VOLUME_SRGB = 833675.435316 # rel. col.
@@ -2028,7 +2038,7 @@ def _ucmm_get_display_profile(display_no, name, path_only=False, use_cache=True)
20282038 return ICCProfile (profile_path , use_cache = use_cache )
20292039
20302040
2031- if mscms :
2041+ if mscms_present :
20322042 def _wcs_get_display_profile (
20332043 devicekey ,
20342044 scope = WCS_PROF_SCOPE .CURRENT_USER ,
@@ -2038,7 +2048,7 @@ def _wcs_get_display_profile(
20382048 path_only = False ,
20392049 use_cache = True ,
20402050 ):
2041- prof = mscms .get_default_color_profile (scope , devicekey , profile_type , profile_subtype , profile_id )
2051+ prof = get_mscms () .get_default_color_profile (scope , devicekey , profile_type , profile_subtype , profile_id )
20422052
20432053 if prof :
20442054 if path_only :
@@ -2173,7 +2183,7 @@ def get_display_profile_windows(
21732183 # EnumDisplayMonitors
21742184 monitors = util_win .get_real_display_devices_info ()
21752185 moninfo = monitors [display_no ]
2176- if not mscms and not devicekey :
2186+ if not mscms_present and not devicekey :
21772187 # Via GetICMProfile. Sucks royally in a multi-monitor setup
21782188 # where one monitor is disabled, because it'll always get
21792189 # the profile of the first monitor regardless if that is the active
@@ -2210,7 +2220,7 @@ def get_display_profile_windows(
22102220 if device :
22112221 devicekey = device .DeviceKey
22122222 if devicekey :
2213- if mscms :
2223+ if mscms_present :
22142224 # Via WCS
22152225 if util_win .per_user_profiles_isenabled (devicekey = devicekey ):
22162226 scope = WCS_PROF_SCOPE .CURRENT_USER
@@ -2398,13 +2408,13 @@ def set_display_profile(
23982408 if not device :
23992409 return False
24002410 devicekey = device .DeviceKey
2401- if mscms :
2411+ if mscms_present :
24022412 if util_win .per_user_profiles_isenabled (devicekey = devicekey ):
24032413 scope = WCS_PROF_SCOPE .CURRENT_USER
24042414 else :
24052415 scope = WCS_PROF_SCOPE .SYSTEM_WIDE
24062416
2407- mscms .associate_color_profile_with_device (scope , profile_name , str (devicekey ))
2417+ get_mscms () .associate_color_profile_with_device (scope , profile_name , str (devicekey ))
24082418 return True
24092419 else :
24102420 # TODO: Implement for XP
@@ -2421,14 +2431,14 @@ def unset_display_profile(
24212431 if not device :
24222432 return False
24232433 devicekey = device .DeviceKey
2424- if mscms :
2434+ if mscms_present :
24252435 if util_win .per_user_profiles_isenabled (devicekey = devicekey ):
24262436 scope = WCS_PROF_SCOPE .CURRENT_USER
24272437 else :
24282438 scope = WCS_PROF_SCOPE .SYSTEM_WIDE
24292439
2430- mscms .disassociate_color_profile_from_device (scope , profile_name , str (devicekey ))
2431- profiles = mscms .get_device_color_profile_list (scope , str (devicekey ))
2440+ get_mscms () .disassociate_color_profile_from_device (scope , profile_name , str (devicekey ))
2441+ profiles = get_mscms () .get_device_color_profile_list (scope , str (devicekey ))
24322442 if profile_name not in profiles :
24332443 return True
24342444 else :
@@ -2444,13 +2454,13 @@ def set_default_display_profile(
24442454 if not device :
24452455 return False
24462456 devicekey = device .DeviceKey
2447- if mscms :
2457+ if mscms_present :
24482458 if util_win .per_user_profiles_isenabled (devicekey = devicekey ):
24492459 scope = WCS_PROF_SCOPE .CURRENT_USER
24502460 else :
24512461 scope = WCS_PROF_SCOPE .SYSTEM_WIDE
24522462
2453- mscms .set_default_color_profile (scope , str (devicekey ), profile_name )
2463+ get_mscms () .set_default_color_profile (scope , str (devicekey ), profile_name )
24542464 return True
24552465 else :
24562466 # TODO: Implement for XP
0 commit comments