199 lines
4.8 KiB
Diff
199 lines
4.8 KiB
Diff
diff -ru a/src/main.c b/src/main.c
|
|
--- a/src/main.c 2023-05-02 04:01:31.000000000 +0300
|
|
+++ b/src/main.c 2023-05-25 03:19:55.506674695 +0300
|
|
@@ -17,77 +17,21 @@
|
|
*/
|
|
|
|
#include <glib/gi18n.h>
|
|
-#include <signal.h>
|
|
|
|
#include "exm-config.h"
|
|
#include "exm-application.h"
|
|
|
|
-#include "exm-backtrace.h"
|
|
-#include "exm-error-dialog.h"
|
|
-
|
|
-#define APP_URL "https://github.com/mjakeman/extension-manager"
|
|
-
|
|
-static int pipe_fd[2];
|
|
-
|
|
-void
|
|
-handler (int sig)
|
|
-{
|
|
- const char *backtrace;
|
|
-
|
|
- g_print ("A fatal error has occurred.\n");
|
|
- g_print ("Please report this to '%s' and attach the following crash report:\n\n", APP_URL);
|
|
-
|
|
- g_print ("START BACKTRACE\n\n");
|
|
- backtrace = exm_backtrace_print ();
|
|
- g_print ("%s\n", backtrace);
|
|
- g_print ("END BACKTRACE\n\n");
|
|
-
|
|
- if (backtrace)
|
|
- {
|
|
- // Send backtrace string over pipe
|
|
- write (pipe_fd[1], backtrace, strlen (backtrace));
|
|
- }
|
|
-
|
|
- close (pipe_fd[1]);
|
|
-
|
|
- // Terminate process
|
|
- signal (sig, SIG_DFL);
|
|
- kill (getpid (), sig);
|
|
-}
|
|
-
|
|
-static void
|
|
-run_crash_reporter (const char *error_text)
|
|
-{
|
|
- adw_init ();
|
|
-
|
|
- // Setup CSS
|
|
- GdkDisplay *display = gdk_display_get_default ();
|
|
- GtkCssProvider *provider = gtk_css_provider_new ();
|
|
- gtk_css_provider_load_from_resource (provider, "/com/mattjakeman/ExtensionManager/style.css");
|
|
- gtk_style_context_add_provider_for_display (display, GTK_STYLE_PROVIDER (provider),
|
|
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
-
|
|
- // Show error dialog with provided string
|
|
- ExmErrorDialog *err_dialog;
|
|
- err_dialog = exm_error_dialog_new (error_text);
|
|
-
|
|
- gtk_window_present (GTK_WINDOW (err_dialog));
|
|
-
|
|
- // Iterate main loop until closed
|
|
- while (g_list_model_get_n_items (gtk_window_get_toplevels ()) > 0)
|
|
- g_main_context_iteration (NULL, TRUE);
|
|
-}
|
|
-
|
|
-static int
|
|
-run_app (int argc,
|
|
- char *argv[])
|
|
+int
|
|
+main (int argc,
|
|
+ char *argv[])
|
|
{
|
|
g_autoptr(ExmApplication) app = NULL;
|
|
- int ret;
|
|
+ int ret;
|
|
|
|
- /* Setup backtrace service */
|
|
- exm_backtrace_init (argv[0]);
|
|
- signal (SIGSEGV, handler);
|
|
+ /* Set up gettext translations */
|
|
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
|
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
+ textdomain (GETTEXT_PACKAGE);
|
|
|
|
/*
|
|
* Create a new GtkApplication. The application manages our main loop,
|
|
@@ -110,74 +54,3 @@
|
|
|
|
return ret;
|
|
}
|
|
-
|
|
-int
|
|
-main (int argc,
|
|
- char *argv[])
|
|
-{
|
|
- gboolean use_crash_reporter;
|
|
- int pid;
|
|
-
|
|
- // Either side of the pipe
|
|
-
|
|
- use_crash_reporter = TRUE;
|
|
-
|
|
- // Set up gettext translations
|
|
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
|
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
- textdomain (GETTEXT_PACKAGE);
|
|
-
|
|
- // Attempt to create the pipe
|
|
- if (pipe (pipe_fd) == -1)
|
|
- use_crash_reporter = FALSE;
|
|
-
|
|
- // Run app normally
|
|
- if (!use_crash_reporter)
|
|
- return run_app (argc, argv);
|
|
-
|
|
- // Run the GUI as a subprocess of the crash reporter. Depending
|
|
- // on the exit code, we can display the crash dialog.
|
|
- pid = fork();
|
|
-
|
|
- // Child process
|
|
- if (pid == 0)
|
|
- {
|
|
- // Close reading end of pipe
|
|
- close (pipe_fd[0]);
|
|
-
|
|
- // Run app normally
|
|
- return run_app (argc, argv);
|
|
- }
|
|
-
|
|
- // Parent process
|
|
- else
|
|
- {
|
|
- char ch;
|
|
- GString *string_builder;
|
|
- char *error_text;
|
|
-
|
|
- // Close the writing end of pipe
|
|
- close (pipe_fd [1]);
|
|
-
|
|
- string_builder = g_string_new ("");
|
|
-
|
|
- while (read (pipe_fd[0], &ch, 1) != 0)
|
|
- g_string_append_c (string_builder, ch);
|
|
-
|
|
- // Wait for child to finish
|
|
- waitpid (pid, 0, 0);
|
|
- close (pipe_fd[0]);
|
|
-
|
|
- error_text = g_string_free (string_builder, FALSE);
|
|
-
|
|
- if (strlen (error_text) > 0)
|
|
- {
|
|
- // An error has occurred
|
|
- run_crash_reporter (error_text);
|
|
- g_free (error_text);
|
|
- return -1;
|
|
- }
|
|
-
|
|
- return 0;
|
|
- }
|
|
-}
|
|
diff -ru a/src/meson.build b/src/meson.build
|
|
--- a/src/meson.build 2023-05-02 04:01:31.000000000 +0300
|
|
+++ b/src/meson.build 2023-05-25 03:13:52.478385702 +0300
|
|
@@ -24,12 +24,12 @@
|
|
'exm-upgrade-assistant.c',
|
|
'exm-upgrade-result.c',
|
|
'exm-install-button.c',
|
|
- 'exm-backtrace.c',
|
|
+ #'exm-backtrace.c',
|
|
'exm-utils.c'
|
|
]
|
|
|
|
cc = meson.get_compiler('c')
|
|
-libbacktrace_dep = cc.find_library('backtrace', required: true)
|
|
+#libbacktrace_dep = cc.find_library('backtrace', required: true)
|
|
|
|
exm_deps = [
|
|
dependency('gtk4'),
|
|
@@ -38,7 +38,7 @@
|
|
dependency('json-glib-1.0'),
|
|
dependency('libsoup-3.0'),
|
|
dependency('text-engine-0.1'),
|
|
- libbacktrace_dep
|
|
+ #libbacktrace_dep
|
|
]
|
|
|
|
gnome = import('gnome')
|
|
@@ -78,4 +78,4 @@
|
|
executable('extension-manager', exm_sources,
|
|
dependencies: exm_deps,
|
|
install: true,
|
|
-)
|
|
\ No newline at end of file
|
|
+)
|