aboutsummaryrefslogtreecommitdiff
path: root/src/snap.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-07-15 14:51:22 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-07-15 14:51:22 -0500
commitd2078fd450a3a631c57dc13c61b35af0ce27d070 (patch)
treef0b06f0f100b18b0fb4a491aa859665916a14ef4 /src/snap.cpp
parenteb8054f0ae27ce06b8c152edceddac94b5685c07 (diff)
downloadayatana-indicator-datetime-d2078fd450a3a631c57dc13c61b35af0ce27d070.tar.gz
ayatana-indicator-datetime-d2078fd450a3a631c57dc13c61b35af0ce27d070.tar.bz2
ayatana-indicator-datetime-d2078fd450a3a631c57dc13c61b35af0ce27d070.zip
Pair notify_init() with a shutdown call to notify_uninit() when the last Snap Decision is closed.
This is needed in the dbusmock tests because libnotify's bus proxy needs to be closed. For production, this doesn't make much change: only that notify_uninit() is called once when the local Snap object goes out of scope in main().
Diffstat (limited to 'src/snap.cpp')
-rw-r--r--src/snap.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/snap.cpp b/src/snap.cpp
index fe8e7f2..45eb14e 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -216,14 +216,6 @@ public:
m_interactive(get_interactive()),
m_sound_builder(sound_builder)
{
- // ensure notify_init() is called once
- // before we start popping up dialogs
- static std::once_flag once;
- std::call_once(once, [](){
- if(!notify_init("indicator-datetime-service"))
- g_critical("libnotify initialization failed");
- });
-
show();
}
@@ -421,6 +413,8 @@ std::string get_alarm_uri(const Appointment& appointment,
return uri;
}
+int32_t n_existing_snaps = 0;
+
} // unnamed namespace
/***
@@ -432,10 +426,14 @@ Snap::Snap(const std::shared_ptr<Clock>& clock,
m_clock(clock),
m_settings(settings)
{
+ if (!n_existing_snaps++ && !notify_init("indicator-datetime-service"))
+ g_critical("libnotify initialization failed");
}
Snap::~Snap()
{
+ if (!--n_existing_snaps)
+ notify_uninit();
}
void Snap::operator()(const Appointment& appointment,