]> git.pld-linux.org Git - packages/apcupsd.git/blame - fixgui.patch
- updated to 3.14.14, adjusted configure patch for current autotools
[packages/apcupsd.git] / fixgui.patch
CommitLineData
76fc6305
ER
1fix crash in gui, rhbz#578276
2https://bugzilla.redhat.com/show_bug.cgi?id=578276
3
4--- apcupsd-3.14.9/src/gapcmon/gapcmon.c.timeout 2008-09-16 06:58:20.000000000 +0200
5+++ apcupsd-3.14.9/src/gapcmon/gapcmon.c 2011-10-12 20:10:52.986362156 +0200
6@@ -179,6 +179,54 @@ struct hostent * gethostname_re
7 */
8 static gboolean lg_graph_debug = FALSE;
9
10+static GSList *timeout_list = NULL;
11+
12+static inline timeout_t * new_timeout(guint id, timeout_type_t type, void *data) {
13+ timeout_t *timeout = (timeout_t *) malloc(sizeof(timeout_t));
14+
15+ timeout->id = id;
16+ timeout->type = type;
17+ timeout->data = data;
18+ return timeout;
19+}
20+
21+/* callback will check if timeout is associated with window
22+ * which is about to be destroyed and it will call g_source_remove
23+ * in order to prevent the callback associated with timeout to be executed
24+ */
25+static void remove_timeout(gpointer tmo, gpointer data) {
26+ timeout_t * timeout = (timeout_t *) tmo;
27+ PGAPC_MONITOR monitor = (PGAPC_MONITOR) data;
28+ int delete_timeout = 0;
29+
30+ if (timeout == NULL) {
31+ return;
32+ }
33+
34+ switch (timeout->type) {
35+ case GRAPH:
36+ if (timeout->data == (void *) monitor->phs.plg) {
37+ delete_timeout = 1;
38+ }
39+ break;
40+ case MONITOR:
41+ if (timeout->data == (void *) monitor) {
42+ delete_timeout = 1;
43+ }
44+ break;
45+
46+ case HISTORY:
47+ if (timeout->data == (void *) &(monitor->phs)) {
48+ delete_timeout = 1;
49+ }
50+ break;
51+ }
52+
53+ if (delete_timeout) {
54+ g_source_remove(timeout->id);
55+ timeout_list = g_slist_remove(timeout_list, (gconstpointer) timeout);
56+ }
57+}
58
59 /* ************************************************************************* */
60
61@@ -1376,8 +1424,8 @@ static gint lg_graph_configure_event_cb
62 plg->x_range.i_minor_inc = plg->plot_box.width / plg->x_range.i_num_minor;
63 plg->x_range.i_major_inc = plg->plot_box.width / plg->x_range.i_num_major;
64
65- g_timeout_add (250, (GSourceFunc) lg_graph_draw, plg);
66-
67+ guint tid = g_timeout_add (250, (GSourceFunc) lg_graph_draw, plg);
68+ timeout_list = g_slist_append(timeout_list, new_timeout(tid, GRAPH, (void *) plg));
69 return TRUE;
70 }
71
72@@ -1745,7 +1793,8 @@ static gboolean cb_monitor_automatic_ref
73 return FALSE; /* stop timers */
74
75 if (pm->b_timer_control) {
76- g_timeout_add(100, (GSourceFunc) cb_monitor_refresh_control, pm);
77+ guint tid = g_timeout_add(100, (GSourceFunc) cb_monitor_refresh_control, pm);
78+ timeout_list = g_slist_append(timeout_list, new_timeout(tid, MONITOR, (void *) pm));
79 return FALSE;
80 }
81
82@@ -4543,9 +4592,9 @@ static void cb_monitor_interface_button_
83 }
84
85 g_async_queue_push(pm->q_network, pm);
86- g_timeout_add(GAPC_REFRESH_FACTOR_ONE_TIME,
87+ guint tid = g_timeout_add(GAPC_REFRESH_FACTOR_ONE_TIME,
88 (GSourceFunc) cb_monitor_dedicated_one_time_refresh, pm);
89-
90+ timeout_list = g_slist_append(timeout_list, new_timeout(tid, MONITOR, (void *) pm));
91 return;
92 }
93
94@@ -5174,6 +5223,9 @@ static void cb_monitor_interface_destroy
95 g_source_remove(pm->tid_automatic_refresh);
96 }
97
98+ /* iterate through list of timers and remove all timers associated with this monitor */
99+ g_slist_foreach(timeout_list, remove_timeout, (gpointer) pm);
100+
101 if (pm->tid_thread_qwork != NULL) {
102 pm->b_thread_stop = TRUE;
103 g_async_queue_push(pm->q_network, pm);
104@@ -5537,9 +5589,9 @@ static gint gapc_monitor_history_page(PG
105
106 /* collect one right away */
107 pphs->b_startup = TRUE;
108- g_timeout_add((guint) (pm->d_refresh * GAPC_REFRESH_FACTOR_1K + 75),
109+ guint tid = g_timeout_add((guint) (pm->d_refresh * GAPC_REFRESH_FACTOR_1K + 75),
110 (GSourceFunc) cb_util_line_chart_refresh, pphs);
111-
112+ timeout_list = g_slist_append(timeout_list, new_timeout(tid, HISTORY, (void *) pphs));
113 return i_page;
114 }
115
116@@ -5565,7 +5617,8 @@ static gboolean cb_util_line_chart_refre
117 return FALSE;
118
119 if (pm->b_graph_control) {
120- g_timeout_add(100, (GSourceFunc) cb_util_line_chart_refresh_control, pm);
121+ guint tid = g_timeout_add(100, (GSourceFunc) cb_util_line_chart_refresh_control, pm);
122+ timeout_list = g_slist_append(timeout_list, new_timeout(tid, MONITOR, (void *) pm));
123 return FALSE;
124 }
125
126@@ -6392,6 +6445,7 @@ extern int main(int argc, char *argv[])
127 PGAPC_CONFIG pcfg = NULL;
128 GtkWidget *window = NULL;
129
130+ timeout_list = g_slist_alloc();
131 /*
132 * Initialize GLib thread support, and GTK
133 */
134@@ -6435,5 +6489,6 @@ extern int main(int argc, char *argv[])
135 gdk_flush();
136 gdk_threads_leave();
137
138+ g_slist_free(timeout_list);
139 return (0);
140 }
141--- apcupsd-3.14.9/src/gapcmon/gapcmon.h 2011-10-12 20:12:54.584317583 +0200
142+++ apcupsd-3.14.9/src/gapcmon/gapcmon.h.timeout 2011-10-12 20:14:10.965669911 +0200
143@@ -403,6 +403,18 @@ typedef struct _System_Control_Data {
144
145 } GAPC_CONFIG, *PGAPC_CONFIG;
146
147+typedef enum {
148+ GRAPH,
149+ MONITOR,
150+ HISTORY
151+} timeout_type_t;
152+
153+typedef struct {
154+ guint id;
155+ timeout_type_t type;
156+ void *data;
157+} timeout_t;
158+
159 /* ************************************************************************* */
160
161 #define GAPC_GLOSSARY "<span size=\"xx-large\"><b>GAPCMON</b></span>\n \
This page took 0.086378 seconds and 4 git commands to generate.