diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index a85cd12374..5eb29b3e3e 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1651,10 +1651,15 @@ if iswindows: msg = ctypes.wintypes.MSG.from_address(message.__int__()) # https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-settingchange if msg.message == 0x001A and msg.lParam: # WM_SETTINGCHANGE - if ctypes.wstring_at(msg.lParam) == 'ImmersiveColorSet': - QApplication.instance().check_for_windows_palette_change() - # prevent Qt from handling this event - return True, 0 + try: + s = ctypes.wstring_at(msg.lParam) + except OSError: + pass + else: + if s == 'ImmersiveColorSet': + QApplication.instance().check_for_windows_palette_change() + # prevent Qt from handling this event + return True, 0 return False, 0