From 90ce77e8139f54ba35bc6bb1ef6bd5be2334ea94 Mon Sep 17 00:00:00 2001 From: "Romain F. T" Date: Wed, 26 May 2021 03:09:40 +0200 Subject: [PATCH] =?UTF-8?q?Better=20manage=20the=20"report=20a=20bug"=20ac?= =?UTF-8?q?tion,=20so=20it=20exists=20and=20is=20suggested=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...to the user when the window initialisation process fails, regardless of whether or not it's a beta version of the app --- src/main.py | 3 +-- src/ui/app-menus.ui | 1 - src/ui/win-menus.ui | 15 --------------- src/ui/window.ui | 2 +- src/window.py | 19 ++++++++++--------- 5 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/main.py b/src/main.py index 3df4933a..4c95f4a8 100644 --- a/src/main.py +++ b/src/main.py @@ -84,8 +84,7 @@ def _build_actions(self): """Add all app-wide actions.""" self.add_action_simple('new_window', self.on_new_window, ['n']) self.add_action_simple('settings', self.on_prefs, None) - if self.is_beta(): - self.add_action_simple('report_bug', self.on_report, None) + self.add_action_simple('report_bug', self.on_report, None) self.add_action_simple('shortcuts', self.on_shortcuts, \ ['question', 'F1']) diff --git a/src/ui/app-menus.ui b/src/ui/app-menus.ui index c1f56ef6..ef269f7a 100644 --- a/src/ui/app-menus.ui +++ b/src/ui/app-menus.ui @@ -435,7 +435,6 @@ Report a bug app.report_bug - action-missing dialog-error-symbolic diff --git a/src/ui/win-menus.ui b/src/ui/win-menus.ui index 22dd9206..252b492b 100644 --- a/src/ui/win-menus.ui +++ b/src/ui/win-menus.ui @@ -91,11 +91,6 @@
- - Report a bug - app.report_bug - action-missing - Shortcuts app.shortcuts @@ -166,11 +161,6 @@
- - Report a bug - app.report_bug - action-missing - Shortcuts app.shortcuts @@ -216,11 +206,6 @@
- - Report a bug - app.report_bug - action-missing - Shortcuts app.shortcuts diff --git a/src/ui/window.ui b/src/ui/window.ui index 94fa577e..b0e6331d 100644 --- a/src/ui/window.ui +++ b/src/ui/window.ui @@ -41,7 +41,7 @@ True True - Error starting the application, please report this bug. + Loading… diff --git a/src/window.py b/src/window.py index 9a827da3..57315f78 100644 --- a/src/window.py +++ b/src/window.py @@ -16,7 +16,7 @@ # along with this program. If not, see . # Import libs -import os +import os, traceback from gi.repository import Gtk, Gdk, Gio, GdkPixbuf, GLib # Import tools @@ -118,7 +118,9 @@ def init_window_content(self, gfile, get_cb): popovers, the tools, their options, and a new image. Depending on the parameters, the new image can be imported from the clipboard, loaded from a GioFile, or (else) it can be a blank image.""" - self.tools = None + self.prompt_action(_("Error starting the application, please report this bug.")) + + self.tools = {} self.minimap = DrMinimap(self, None) self.options_manager = DrOptionsManager(self) self.saving_manager = DrSavingManager(self) @@ -231,14 +233,13 @@ def _enable_first_tool(self): def _load_tool(self, tool_id, tool_class, disabled_tools, dev): """Given its id and its python class, this method tries to load a tool, and show an error message if the tool initialization failed.""" - if dev: # Simplest way to get an error stack - self.tools[tool_id] = tool_class(self) - elif tool_id not in disabled_tools: + if tool_id not in disabled_tools: try: self.tools[tool_id] = tool_class(self) - except: + except Exception as err: # Context: an error message - self.prompt_message(True, _("Failed to load tool: %s") % tool_id) + self.prompt_action(_("Failed to load tool: %s") % tool_id) + traceback.print_exc() def _build_tool_rows(self): """Adds each tool's button to the side pane.""" @@ -708,10 +709,10 @@ def prompt_message(self, show, label): self.info_action.set_visible(False) if show: self.info_label.set_label(label) - if show or self.gsettings.get_boolean('devel-only') and label != "": + if show and self.gsettings.get_boolean('devel-only') and label != "": print('Drawing: ' + label) - def prompt_action(self, message, action_name, action_label): + def prompt_action(self, message, action_name='app.report_bug', action_label=_("Report a bug")): """Update the content of the info bar, including its actionable button which is set as visible.""" self.prompt_message(True, message)