[geary/mjog/misc-fixes: 4/5] Allow ProblemDetailsDialog to be show without a MainWindow



commit c07b878b09c49bc50193927701c0af2018e6577d
Author: Michael Gratton <mike vee net>
Date:   Mon Dec 2 20:00:15 2019 +0800

    Allow ProblemDetailsDialog to be show without a MainWindow
    
    This lets it be used for app startup problems.

 src/client/components/main-window-info-bar.vala        | 13 ++++++++-----
 src/client/dialogs/dialogs-problem-details-dialog.vala |  7 ++++---
 2 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/client/components/main-window-info-bar.vala b/src/client/components/main-window-info-bar.vala
index 1a737fc2..5b20660c 100644
--- a/src/client/components/main-window-info-bar.vala
+++ b/src/client/components/main-window-info-bar.vala
@@ -126,13 +126,16 @@ public class MainWindowInfoBar : Gtk.InfoBar {
     }
 
     private void show_details() {
-        Dialogs.ProblemDetailsDialog dialog =
-            new Dialogs.ProblemDetailsDialog(
-                get_toplevel() as Application.MainWindow,
+        var main = get_toplevel() as Application.MainWindow;
+        if (main != null) {
+            var dialog = new Dialogs.ProblemDetailsDialog(
+                main,
+                main.application,
                 this.report
             );
-        dialog.run();
-        dialog.destroy();
+            dialog.run();
+            dialog.destroy();
+        }
     }
 
     [GtkCallback]
diff --git a/src/client/dialogs/dialogs-problem-details-dialog.vala 
b/src/client/dialogs/dialogs-problem-details-dialog.vala
index 5f0ebb32..2dcfcb0c 100644
--- a/src/client/dialogs/dialogs-problem-details-dialog.vala
+++ b/src/client/dialogs/dialogs-problem-details-dialog.vala
@@ -51,7 +51,8 @@ public class Dialogs.ProblemDetailsDialog : Hdy.Dialog {
     private Geary.ServiceInformation? service;
 
 
-    public ProblemDetailsDialog(Application.MainWindow parent,
+    public ProblemDetailsDialog(Gtk.Window? parent,
+                                Application.Client application,
                                 Geary.ProblemReport report) {
         Object(
             transient_for: parent,
@@ -83,7 +84,7 @@ public class Dialogs.ProblemDetailsDialog : Hdy.Dialog {
         );
 
         this.log_pane = new Components.InspectorLogView(
-            parent.application.config, account
+            application.config, account
         );
         this.log_pane.load(report.earliest_log, report.latest_log);
         this.log_pane.record_selection_changed.connect(
@@ -91,7 +92,7 @@ public class Dialogs.ProblemDetailsDialog : Hdy.Dialog {
         );
 
         this.system_pane = new Components.InspectorSystemView(
-            parent.application
+            application
         );
 
         /// Translators: Title for problem report dialog error


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]