summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUnity <unity@VB-U1010.(none)>2010-12-02 01:04:37 +0800
committerUnity <unity@VB-U1010.(none)>2010-12-02 01:04:37 +0800
commit3f462d97acf5a095dbc034ca6e4468fcdfb48482 (patch)
tree763748bb1bab87959217d3c5b60d384913ff220c /src
parentef1399c6bdd2324000c2f19f55f48a89d1737a51 (diff)
parent81c768f8f3cbd8f2579f161bcc64fd8bc33c57ed (diff)
downloadcompiz-with-glib-mainloop-3f462d97acf5a095dbc034ca6e4468fcdfb48482.tar.gz
compiz-with-glib-mainloop-3f462d97acf5a095dbc034ca6e4468fcdfb48482.tar.bz2
Merge branch 'glibmm-experimental' of git://git.compiz.org/users/dbo/compiz-with-glib-mainloop into glibmm-experimental
Diffstat (limited to 'src')
-rw-r--r--src/privatescreen.h2
-rw-r--r--src/screen.cpp29
2 files changed, 23 insertions, 8 deletions
diff --git a/src/privatescreen.h b/src/privatescreen.h
index 1e73561..725c43d 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -356,7 +356,7 @@ class PrivateScreen : public CoreOptions {
CompFileWatchList fileWatch;
CompFileWatchHandle lastFileWatchHandle;
- std::list<CompTimer *> timers;
+ std::list <int> removedTimers;
struct timeval lastTimeout;
std::list<Glib::RefPtr <CompWatchFd> > watchFds;
diff --git a/src/screen.cpp b/src/screen.cpp
index 7676a49..4b7d95a 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -245,10 +245,23 @@ CompScreen::getFileWatches () const
/* TODO: move this code to timer.cpp */
bool
-CompTimer::internalCallback ()
+CompTimer::internalCallback (unsigned int id)
{
bool result;
+ /* Detect when the timer is still going and the internal
+ * object has been freed */
+ if (!screen->priv->removedTimers.empty ())
+ {
+ if (std::find (screen->priv->removedTimers.begin (),
+ screen->priv->removedTimers.end (),
+ id) != screen->priv->removedTimers.end ())
+ {
+ screen->priv->removedTimers.remove (id);
+ return false;
+ }
+ }
+
if (!mActive)
return false;
@@ -278,17 +291,20 @@ CompTimer::internalCallback ()
void
PrivateScreen::addTimer (CompTimer *timer)
{
+ unsigned int time = timer->mMinTime;
+ unsigned int id;
+
if (timer->mSource)
return;
- unsigned int time = timer->mMinTime;
-
timer->mSource = Glib::TimeoutSource::create (time);
if (timer->mSource)
{
timer->mSource->attach (priv->ctx);
- timer->mSource->connect (sigc::mem_fun <bool, CompTimer> (timer, &CompTimer::internalCallback));
+ id = g_source_get_id (timer->mSource->gobj ());
+ removedTimers.remove (id);
+ timer->mSource->connect (sigc::bind <unsigned int>(sigc::mem_fun (timer, &CompTimer::internalCallback), id));
timer->tick ();
}
else
@@ -304,6 +320,8 @@ PrivateScreen::removeTimer (CompTimer *timer)
if (timer->mExecuting)
timer->mForceFail = true;
+ removedTimers.push_back (g_source_get_id (timer->mSource->gobj ()));
+
timer->mSource.reset (); /* This will NULL the pointer */
}
@@ -4553,8 +4571,6 @@ CompScreen::~CompScreen ()
{
CompPlugin *p;
- priv->source.reset ();
-
priv->removeAllSequences ();
while (!priv->windows.empty ())
@@ -4598,7 +4614,6 @@ PrivateScreen::PrivateScreen (CompScreen *screen) :
priv (this),
fileWatch (0),
lastFileWatchHandle (1),
- timers (0),
watchFds (0),
lastWatchFdHandle (1),
valueMap (),