Browse Source

fix endless stream of bug report dialogs on SIGSEGV

Also make BugReportDialogWidget a singleton so no more than one can ever
be shown.
libpanel_detach
Alexandros Theodotou 2 months ago
parent
commit
2eb9bd71ba
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 22
      inc/audio/engine.h
  2. 8
      inc/zrythm_app.h
  3. 22
      src/gui/widgets/dialogs/bug_report_dialog.c
  4. 14
      src/utils/log.c
  5. 30
      src/zrythm_app.c

22
inc/audio/engine.h

@ -1,22 +1,6 @@ @@ -1,22 +1,6 @@
/*
* Copyright (C) 2018-2022 Alexandros Theodotou <alex at zrythm dot org>
* Copyright (C) 2020 Ryan Gonzalez <rymg19 at gmail dot com>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2018-2022 Alexandros Theodotou <alex@zrythm.org>
// SPDX-FileCopyrightText: © 2020 Ryan Gonzalez <rymg19 at gmail dot com>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
/**
* \file

8
inc/zrythm_app.h

@ -1,7 +1,5 @@ @@ -1,7 +1,5 @@
// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
/* SPDX-License-Identifier: LicenseRef-ZrythmLicense */
/*
* Copyright (C) 2019-2021 Alexandros Theodotou <alex at zrythm dot org>
*/
/**
* \file
@ -31,6 +29,7 @@ typedef struct _MainWindowWidget MainWindowWidget; @@ -31,6 +29,7 @@ typedef struct _MainWindowWidget MainWindowWidget;
typedef struct _SplashWindowWidget SplashWindowWidget;
typedef struct _FirstRunAssistantWidget FirstRunAssistantWidget;
typedef struct _ProjectAssistantWidget ProjectAssistantWidget;
typedef struct _BugReportDialogWidget BugReportDialogWidget;
typedef struct Zrythm Zrythm;
typedef struct UiCaches UiCaches;
@ -156,6 +155,9 @@ struct _ZrythmApp @@ -156,6 +155,9 @@ struct _ZrythmApp
* loads.
*/
GAsyncQueue * project_load_message_queue;
/** Currently opened bug report dialog. */
BugReportDialogWidget * bug_report_dialog;
};
/**

22
src/gui/widgets/dialogs/bug_report_dialog.c

@ -1,21 +1,5 @@ @@ -1,21 +1,5 @@
/*
* Copyright (C) 2020-2022 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
// SPDX-FileCopyrightText: © 2020-2022 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
#include "zrythm-config.h"
@ -567,6 +551,8 @@ dispose (BugReportDialogWidget * self) @@ -567,6 +551,8 @@ dispose (BugReportDialogWidget * self)
G_OBJECT_CLASS (bug_report_dialog_widget_parent_class)
->dispose (G_OBJECT (self));
zrythm_app->bug_report_dialog = NULL;
}
static void

14
src/utils/log.c

@ -792,17 +792,19 @@ log_idle_cb (Log * self) @@ -792,17 +792,19 @@ log_idle_cb (Log * self)
if (
ev->log_level == G_LOG_LEVEL_CRITICAL
&& ZRYTHM_HAVE_UI)
&& ZRYTHM_HAVE_UI
&& !zrythm_app->bug_report_dialog)
{
char msg[500];
sprintf (
msg, _ ("%s has encountered an error\n"),
PROGRAM_NAME);
BugReportDialogWidget * dialog =
bug_report_dialog_new (
MAIN_WINDOW ? GTK_WINDOW (MAIN_WINDOW) : NULL,
msg, ev->backtrace, false);
gtk_window_present (GTK_WINDOW (dialog));
zrythm_app
->bug_report_dialog = bug_report_dialog_new (
MAIN_WINDOW ? GTK_WINDOW (MAIN_WINDOW) : NULL,
msg, ev->backtrace, false);
gtk_window_present (
GTK_WINDOW (zrythm_app->bug_report_dialog));
}
/* write the backtrace to the log after

30
src/zrythm_app.c

@ -122,7 +122,18 @@ segv_handler (int sig) @@ -122,7 +122,18 @@ segv_handler (int sig)
sprintf (
prefix, _ ("Error: %s - Backtrace:\n"), strsignal (sig));
#endif
char * bt = backtrace_get_with_lines (prefix, 100, true);
/* avoid getting backtraces too often if a bug report dialog
* is already opened - it makes it hard to type due to lag */
char * bt;
if (zrythm_app->bug_report_dialog)
{
bt = g_strdup ("");
}
else
{
bt = backtrace_get_with_lines (prefix, 100, true);
}
/* call the callback to write queued messages
* and get last few lines of the log, before
@ -133,12 +144,17 @@ segv_handler (int sig) @@ -133,12 +144,17 @@ segv_handler (int sig)
if (MAIN_WINDOW)
{
char str[500];
sprintf (str, _ ("%s has crashed. "), PROGRAM_NAME);
BugReportDialogWidget * dialog = bug_report_dialog_new (
GTK_WINDOW (MAIN_WINDOW), str, bt, true);
gtk_window_present (GTK_WINDOW (dialog));
if (!zrythm_app->bug_report_dialog)
{
char str[500];
sprintf (str, _ ("%s has crashed. "), PROGRAM_NAME);
zrythm_app
->bug_report_dialog = bug_report_dialog_new (
GTK_WINDOW (MAIN_WINDOW), str, bt, true);
gtk_window_present (
GTK_WINDOW (zrythm_app->bug_report_dialog));
}
return;
}

Loading…
Cancel
Save