From 4c3a1606f20fff851a35d791a9aeb2e80e99c44a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Sep 2024 07:25:38 +0530 Subject: [PATCH] Make is_dark_theme() not raise an exception when no QApplication is constructed --- src/calibre/gui2/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 2aad89decd06..83cbbf0ff455 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -1002,8 +1002,11 @@ def choose_files_and_remember_all_files( def is_dark_theme(): - pal = QApplication.instance().palette() - return pal.is_dark_theme() + app = QApplication.instance() + if app is not None: + pal = QApplication.instance().palette() + return pal.is_dark_theme() + return False def choose_osx_app(window, name, title, default_dir='/Applications'):