summaryrefslogtreecommitdiffstats
path: root/fix-clock-crash.patch
blob: 4a12b6019f7f58b79df0a58d32d04949ed0c2a96 (plain)
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
From 58d7ba0359ab128f30b39ea0518a69ed83a4e329 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 8 Dec 2009 14:48:58 -0500
Subject: [PATCH] Only call e_passwords_shutdown once

It doesn't appear to support being called multiple times
in a row.

It appears there was already an attempt to do this with a
reference counter called clock_numbers:

/* Used to count the number of clock instances. It's there to know when
 * we should free resources that are shared. */
static int clock_numbers = 0;

But the logic was wrong.
---
 applets/clock/clock.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index ddbbc16..c06530a 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -803,8 +803,11 @@ destroy_clock (GtkWidget * widget, ClockData *cd)
 
 #ifdef HAVE_LIBECAL
 	if (clock_numbers > 0) {
-		e_passwords_shutdown ();
 		clock_numbers--;
+
+		if (clock_numbers == 0) {
+			e_passwords_shutdown ();
+		}
 	}
 #endif
 }
@@ -1385,8 +1388,10 @@ static void
 create_clock_widget (ClockData *cd)
 {
 #ifdef HAVE_LIBECAL
+	if (clock_numbers == 0) {
+		e_passwords_init ();
+	}
 	clock_numbers++;
-	e_passwords_init ();
 #endif
 
         /* Main toggle button */
-- 
1.6.5.2