summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-11-18 18:43:41 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-11-18 18:43:41 +0800
commitc26f860f5e70c20e32a6b2e7b9c611c4f288f89e (patch)
treebac65a46f5a52e9302ce23c409858f4ee2637406 /src
parent1e79952a8d573e211ca194712f7f52fa3df89fb9 (diff)
downloadcompiz-with-glib-mainloop-c26f860f5e70c20e32a6b2e7b9c611c4f288f89e.tar.gz
compiz-with-glib-mainloop-c26f860f5e70c20e32a6b2e7b9c611c4f288f89e.tar.bz2
Fix weird condition where gboolean != bool bitwise which caused timers to segfault on occasion
Diffstat (limited to 'src')
-rw-r--r--src/screen.cpp14
-rw-r--r--src/timer.cpp8
2 files changed, 14 insertions, 8 deletions
diff --git a/src/screen.cpp b/src/screen.cpp
index 2b987d5..76c2ba1 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -288,17 +288,22 @@ onTimerTimeout (CompTimer *timer)
forceFail = false;
executingId = timer->mId;
+
result = timer->mCallBack ();
+ if (forceFail)
+ return false;
+
if (result)
+ {
timer->tick ();
+ return true;
+ }
else
+ {
timer->mId = 0;
-
- if (forceFail)
return false;
-
- return result;
+ }
}
void
@@ -310,6 +315,7 @@ PrivateScreen::addTimer (CompTimer *timer)
unsigned int time = timer->mMinTime;
timer->mId = g_timeout_add (time, (GSourceFunc) onTimerTimeout, timer);
+
timer->tick ();
}
diff --git a/src/timer.cpp b/src/timer.cpp
index 088abf3..964f932 100644
--- a/src/timer.cpp
+++ b/src/timer.cpp
@@ -127,10 +127,10 @@ CompTimer::minLeft ()
{
struct timeval current;
int left;
-
+
gettimeofday (&current, 0);
left = mMinTime - TIMEVALDIFF (&current, &tickStart);
-
+
return (left < 0)? 0 : (unsigned int) left;
}
@@ -139,10 +139,10 @@ CompTimer::maxLeft ()
{
struct timeval current;
int left;
-
+
gettimeofday (&current, 0);
left = mMaxTime - TIMEVALDIFF (&current, &tickStart);
-
+
return (left < 0)? 0 : (unsigned int) left;
}