aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-08-01 12:14:04 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-08-01 12:14:04 -0500
commit56fdc9efed4ceb60fac12e22699cd58afabf6eee (patch)
tree4c609daa2dd6d9e727496845fa4d212422fd513b /src
parentd129112ad9ce04fad979af95b5b5cd4fd87f5b2b (diff)
parent6da58726eb18e7205845ec1af4cb43d08d988e31 (diff)
downloadayatana-indicator-datetime-56fdc9efed4ceb60fac12e22699cd58afabf6eee.tar.gz
ayatana-indicator-datetime-56fdc9efed4ceb60fac12e22699cd58afabf6eee.tar.bz2
ayatana-indicator-datetime-56fdc9efed4ceb60fac12e22699cd58afabf6eee.zip
sync with prerequisite branch lp:~charlesk/indicator-datetime/notification-refactor
Diffstat (limited to 'src')
-rw-r--r--src/notifications.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/notifications.cpp b/src/notifications.cpp
index da7351b..dfb1dc6 100644
--- a/src/notifications.cpp
+++ b/src/notifications.cpp
@@ -156,14 +156,14 @@ public:
void close_all ()
{
- // close() removes the item from m_notifications,
- // so increment the iterator before it gets invalidated
- for (auto it=m_notifications.begin(), e=m_notifications.end(); it!=e; )
- {
- const int key = it->first;
- ++it;
- close (key);
- }
+ // call close() on all our keys
+
+ std::set<int> keys;
+ for (const auto& it : m_notifications)
+ keys.insert (it.first);
+
+ for (const int key : keys)
+ close (key);
}
void close (int key)
@@ -171,15 +171,16 @@ public:
auto it = m_notifications.find(key);
if (it != m_notifications.end())
{
- // tell the server to close, call the close() callback,
- // and immediately forget about the nn.
+ // tell the server to close the notification
GError * error = nullptr;
if (!notify_notification_close (it->second.nn.get(), &error))
{
g_warning ("Unable to close notification %d: %s", key, error->message);
g_error_free (error);
}
- on_closed (key);
+
+ // call the user callback and remove it from our bookkeeping
+ remove_closed_notification (key);
}
}
@@ -270,10 +271,10 @@ private:
{
const GQuark q = notification_key_quark();
const gpointer gkey = g_object_get_qdata(G_OBJECT(nn), q);
- static_cast<Impl*>(gself)->on_closed(GPOINTER_TO_INT(gkey));
+ static_cast<Impl*>(gself)->remove_closed_notification(GPOINTER_TO_INT(gkey));
}
- void on_closed (int key)
+ void remove_closed_notification (int key)
{
auto it = m_notifications.find(key);
g_return_if_fail (it != m_notifications.end());