From 8da42d6a700c2edd3b06948954a0e99b9df46a90 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 5 Aug 2013 10:59:36 +0530 Subject: [PATCH] Do not popup an error dialog for invalid message Do not popup an error dialog when an invalid message is received from another instance, unless we are in DEBUG mode. See #1207947 --- src/calibre/gui2/ui.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 43740876ea..6d2c2d2d14 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -19,7 +19,7 @@ from PyQt4.Qt import (Qt, SIGNAL, QTimer, QHelpEvent, QAction, QDialog, QSystemTrayIcon, QApplication) from calibre import prints, force_unicode -from calibre.constants import __appname__, isosx, filesystem_encoding +from calibre.constants import __appname__, isosx, filesystem_encoding, DEBUG from calibre.utils.config import prefs, dynamic from calibre.utils.ipc.server import Server from calibre.db import get_db_loader @@ -521,7 +521,16 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ return if msg.startswith('launched:'): import json - argv = json.loads(msg[len('launched:'):]) + try: + argv = json.loads(msg[len('launched:'):]) + except ValueError: + prints('Failed to decode message from other instance: %r' % msg) + if DEBUG: + error_dialog(self, 'Invalid message', + 'Received an invalid message from other calibre instance.' + ' Do you have multiple versions of calibre installed?', + det_msg='Invalid msg: %r' % msg, show=True) + argv = () if isinstance(argv, (list, tuple)) and len(argv) > 1: files = [os.path.abspath(p) for p in argv[1:] if not os.path.isdir(p) and os.access(p, os.R_OK)] if files: