Blame 0046-Fix-1839494-Application-crashes-on-changing-icons-ht.patch

5f720ea
From ca70f1f214e54aa6f9a173fb2c28be6f13497341 Mon Sep 17 00:00:00 2001
5f720ea
From: Kovid Goyal <kovid@kovidgoyal.net>
5f720ea
Date: Thu, 8 Aug 2019 22:29:03 +0530
5f720ea
Subject: [PATCH 46/71] Fix #1839494 [Application crashes on changing
5f720ea
 icons](https://bugs.launchpad.net/calibre/+bug/1839494)
5f720ea
5f720ea
---
5f720ea
 src/calibre/gui2/icon_theme.py | 7 ++++++-
5f720ea
 1 file changed, 6 insertions(+), 1 deletion(-)
5f720ea
5f720ea
diff --git a/src/calibre/gui2/icon_theme.py b/src/calibre/gui2/icon_theme.py
5f720ea
index d898561244..c987cb8c81 100644
5f720ea
--- a/src/calibre/gui2/icon_theme.py
5f720ea
+++ b/src/calibre/gui2/icon_theme.py
5f720ea
@@ -18,6 +18,10 @@ from PyQt5.Qt import (
5f720ea
     QGridLayout, QStyledItemDelegate, QApplication, QStaticText,
5f720ea
     QStyle, QPen, QProgressDialog
5f720ea
 )
5f720ea
+try:
5f720ea
+    from PyQt5 import sip
5f720ea
+except ImportError:
5f720ea
+    import sip
5f720ea
 
5f720ea
 from calibre import walk, fit_image, human_readable, detect_ncpus as cpu_count
5f720ea
 from calibre.constants import cache_dir, config_dir
5f720ea
@@ -689,7 +693,8 @@ class ChooseTheme(Dialog):
5f720ea
             import traceback
5f720ea
             self.themes = traceback.format_exc()
5f720ea
         t.join()
5f720ea
-        self.themes_downloaded.emit()
5f720ea
+        if not sip.isdeleted(self):
5f720ea
+            self.themes_downloaded.emit()
5f720ea
 
5f720ea
     def show_themes(self):
5f720ea
         self.end_spinner()