summaryrefslogtreecommitdiffstats
path: root/source/xap/pavucontrol/sigsegv_on_quit.patch
blob: 21a355046bd7aed4b25014bdc78470b7597fe0c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 6fa3480..6d6463a 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -35,6 +35,8 @@
 
 #include "i18n.h"
 
+#include "pavuapplication.h"
+
 /* Used for profile sorting */
 struct profile_prio_compare {
     bool operator() (const pa_card_profile_info2& lhs, const pa_card_profile_info2& rhs) const {
@@ -200,7 +202,6 @@ void MainWindow::on_realize() {
 }
 
 bool MainWindow::on_key_press_event(GdkEventKey* event) {
-
     if (event->state & GDK_CONTROL_MASK) {
         switch (event->keyval) {
             case GDK_KEY_KP_1:
@@ -221,7 +222,7 @@ bool MainWindow::on_key_press_event(GdkEventKey* event) {
             case GDK_KEY_Q:
             case GDK_KEY_w:
             case GDK_KEY_q:
-                Gtk::Main::quit();
+                g_MainApp -> quit();
                 return true;
         }
     }
diff --git a/src/pavuapplication.cc b/src/pavuapplication.cc
index e8520ec..3298c1c 100644
--- a/src/pavuapplication.cc
+++ b/src/pavuapplication.cc
@@ -30,6 +30,9 @@
 #include "pavucontrol.h"
 #include "mainwindow.h"
 
+
+std::unique_ptr<PavuApplication> g_MainApp;
+
 PavuApplication::PavuApplication() :
     Gtk::Application("org.pulseaudio.pavucontrol", Gio::ApplicationFlags::APPLICATION_HANDLES_COMMAND_LINE),
     mainWindow(NULL),
@@ -143,26 +146,26 @@ int main(int argc, char *argv[]) {
     signal(SIGPIPE, SIG_IGN);
 
     /* Create the application */
-    auto app = PavuApplication();
+    g_MainApp = std::unique_ptr<PavuApplication>(new PavuApplication());
 
     /* Add command-line options */
-    app.add_main_option_entry(
+    g_MainApp->add_main_option_entry(
         Gio::Application::OptionType::OPTION_TYPE_INT,
         "tab", 't',
         _("Select a specific tab on load."),
         _("number"));
 
-    app.add_main_option_entry(
+    g_MainApp->add_main_option_entry(
         Gio::Application::OptionType::OPTION_TYPE_BOOL,
         "retry", 'r',
         _("Retry forever if pa quits (every 5 seconds)."));
 
-    app.add_main_option_entry(
+    g_MainApp->add_main_option_entry(
         Gio::Application::OptionType::OPTION_TYPE_BOOL,
         "maximize", 'm',
         _("Maximize the window."));
 
-    app.add_main_option_entry(
+    g_MainApp->add_main_option_entry(
         Gio::Application::OptionType::OPTION_TYPE_BOOL,
         "version", 'v',
         _("Show version."));
@@ -170,7 +173,7 @@ int main(int argc, char *argv[]) {
     /* Connect to the "on_command_line" signal which is fired
      * when the application receives command-line arguments
      */
-    app.signal_command_line().connect(sigc::bind(sigc::ptr_fun(&on_command_line), &app), false);
+    g_MainApp->signal_command_line().connect(sigc::bind(sigc::ptr_fun(&on_command_line), g_MainApp.get()), false);
 
     /* Run the application.
      * In the first launched instance, this will return when its window is
@@ -179,5 +182,5 @@ int main(int argc, char *argv[]) {
      * Handling a new request consists of presenting the existing window (and
      * optionally, select a tab).
      */
-    return app.run(argc, argv);
+     return g_MainApp->run(argc, argv);
 }
diff --git a/src/pavuapplication.h b/src/pavuapplication.h
index 3589c5d..ba56dc9 100644
--- a/src/pavuapplication.h
+++ b/src/pavuapplication.h
@@ -21,6 +21,7 @@
 #ifndef pavuapplication_h
 #define pavuapplication_h
 
+#include <memory>
 #include "pavucontrol.h"
 #include "mainwindow.h"
 
@@ -49,4 +50,6 @@ private:
 };
 
 
+extern std::unique_ptr<PavuApplication> g_MainApp;
+
 #endif
diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index 6981707..dbdf92a 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -40,6 +40,7 @@
 #include "sourceoutputwidget.h"
 #include "rolewidget.h"
 #include "mainwindow.h"
+#include "pavuapplication.h"
 
 static pa_context* context = NULL;
 static pa_mainloop_api* api = NULL;
@@ -56,7 +57,7 @@ void show_error(const char *txt) {
     Gtk::MessageDialog dialog(buf, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
     dialog.run();
 
-    Gtk::Main::quit();
+	g_MainApp ->quit();
 }
 
 static void dec_outstanding(MainWindow *w) {
@@ -571,7 +572,7 @@ void context_state_callback(pa_context *c, void *userdata) {
 
         case PA_CONTEXT_TERMINATED:
         default:
-            Gtk::Main::quit();
+			g_MainApp ->quit();
             return;
     }
 }
@@ -613,7 +614,7 @@ gboolean connect_to_pulse(gpointer userdata) {
         else {
             if(!retry) {
                 reconnect_timeout = -1;
-                Gtk::Main::quit();
+                g_MainApp ->quit();
             } else {
                 g_debug(_("Connection failed, attempting reconnect"));
                 reconnect_timeout = 5;