From dad004e03c74d201188f9bb8d0921ba611a708a0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 26 Apr 2014 14:25:47 +0530 Subject: [PATCH] Remove the notify() debug redirection as it greatly slows down startup and also causes hangs in some not fully understood situations --- src/calibre/gui2/__init__.py | 11 ----------- .../gui2/progress_indicator/QProgressIndicator.cpp | 12 ------------ .../gui2/progress_indicator/QProgressIndicator.h | 10 ---------- .../gui2/progress_indicator/QProgressIndicator.sip | 4 ---- 4 files changed, 37 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 08028c9bf6..3da761fa19 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -882,8 +882,6 @@ class Application(QApplication): args = [override_program_name] + args[1:] qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args] self.pi = plugins['progress_indicator'][0] - if DEBUG: - self.redirect_notify = True self.setup_styles(force_calibre_style) QApplication.__init__(self, qargs) f = QFont(QApplication.font()) @@ -913,15 +911,6 @@ class Application(QApplication): qt_app = self self._file_open_paths = [] self._file_open_lock = RLock() - if DEBUG: - def notify(self, receiver, event): - if self.redirect_notify: - self.redirect_notify = False - return self.pi.do_notify(receiver, event) - else: - ret = QApplication.notify(self, receiver, event) - self.redirect_notify = True - return ret def load_builtin_fonts(self, scan_for_fonts=False): if scan_for_fonts: diff --git a/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp b/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp index e2d2920fe9..ac307110b0 100644 --- a/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp +++ b/src/calibre/gui2/progress_indicator/QProgressIndicator.cpp @@ -219,18 +219,6 @@ int load_style(QHash icon_map) { return 0; } -bool do_notify(QObject *receiver, QEvent *event) { - try { - return QApplication::instance()->notify(receiver, event); - } catch (std::exception& e) { - qCritical() << "C++ exception thrown in slot: " << e.what(); - } catch (...) { - qCritical() << "Unknown C++ exception thrown in slot"; - } - qCritical() << "Receiver name:" << receiver->objectName() << "Receiver class:" << receiver->metaObject()->className() << "Event type: " << event->type(); - return false; -} - class NoActivateStyle: public QProxyStyle { public: int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const { diff --git a/src/calibre/gui2/progress_indicator/QProgressIndicator.h b/src/calibre/gui2/progress_indicator/QProgressIndicator.h index 3d67f9c7ab..95390cc6cf 100644 --- a/src/calibre/gui2/progress_indicator/QProgressIndicator.h +++ b/src/calibre/gui2/progress_indicator/QProgressIndicator.h @@ -92,16 +92,6 @@ private: QColor m_color; }; -/* Utility function that can be used to load a QStyle from a Qt plugin. This is - * here so that there is no need to create a separate PyQt plugin just for this - * simple functionality. - * \param path The full path to the DLL containing the plugin - * \param name The name of the style plugin to load - * \return 1 if succeeds 0 otherwise. The objectName of the loaded style is set to name - */ int load_style(QHash icon_map); - -bool do_notify(QObject *receiver, QEvent *event); - void set_no_activate_on_click(QWidget *widget); void set_touch_menu_style(QWidget *widget, int margin=14); diff --git a/src/calibre/gui2/progress_indicator/QProgressIndicator.sip b/src/calibre/gui2/progress_indicator/QProgressIndicator.sip index f59a400584..71f7060a61 100644 --- a/src/calibre/gui2/progress_indicator/QProgressIndicator.sip +++ b/src/calibre/gui2/progress_indicator/QProgressIndicator.sip @@ -7,7 +7,6 @@ %ModuleHeaderCode int load_style(QHash icon_map); -bool do_notify(QObject *receiver, QEvent *event); void set_no_activate_on_click(QWidget *widget); void set_touch_menu_style(QWidget *widget, int margin); %End @@ -58,8 +57,5 @@ protected: }; int load_style(QHash icon_map); - -bool do_notify(QObject *receiver, QEvent *event); - void set_no_activate_on_click(QWidget *widget); void set_touch_menu_style(QWidget *widget, int margin=20);