diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2015-03-16 18:18:15 +0100 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2015-03-16 18:18:15 +0100 |
commit | 76c4567c8c674483e9e3b7286f78ab45115a8cf9 (patch) | |
tree | e06f8e99a4c72f22edf9e95ccce706d17063a8d1 /src | |
parent | 4dd066bb3534fe84ec4eed285422f043695febb7 (diff) | |
download | ayatana-indicator-datetime-76c4567c8c674483e9e3b7286f78ab45115a8cf9.tar.gz ayatana-indicator-datetime-76c4567c8c674483e9e3b7286f78ab45115a8cf9.tar.bz2 ayatana-indicator-datetime-76c4567c8c674483e9e3b7286f78ab45115a8cf9.zip |
in DateTime::DateTime(GTimeZone*,GDateTime*), don't allow either argument to be nullptr
Diffstat (limited to 'src')
-rw-r--r-- | src/date-time.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/date-time.cpp b/src/date-time.cpp index 46591e6..47ca047 100644 --- a/src/date-time.cpp +++ b/src/date-time.cpp @@ -33,7 +33,8 @@ DateTime::DateTime() DateTime::DateTime(GTimeZone* gtz, GDateTime* gdt) { - g_return_if_fail((gtz==nullptr) == (gdt==nullptr)); + g_return_if_fail(gtz!=nullptr); + g_return_if_fail(gdt!=nullptr); reset(gtz, gdt); } @@ -175,29 +176,14 @@ int64_t DateTime::to_unix() const void DateTime::reset(GTimeZone* gtz, GDateTime* gdt) { - g_return_if_fail ((gdt==nullptr) == (gtz==nullptr)); // all or nothin' + g_return_if_fail (gdt!=nullptr); + g_return_if_fail (gtz!=nullptr); - if (gtz) - { - auto deleter = [](GTimeZone* tz){g_time_zone_unref(tz);}; - m_tz = std::shared_ptr<GTimeZone>(g_time_zone_ref(gtz), deleter); - g_assert(m_tz); - } - else - { - m_tz.reset(); - } - - if (gdt) - { - auto deleter = [](GDateTime* dt){g_date_time_unref(dt);}; - m_dt = std::shared_ptr<GDateTime>(g_date_time_ref(gdt), deleter); - g_assert(m_dt); - } - else - { - m_dt.reset(); - } + auto tz_deleter = [](GTimeZone* tz){g_time_zone_unref(tz);}; + m_tz = std::shared_ptr<GTimeZone>(g_time_zone_ref(gtz), tz_deleter); + + auto dt_deleter = [](GDateTime* dt){g_date_time_unref(dt);}; + m_dt = std::shared_ptr<GDateTime>(g_date_time_ref(gdt), dt_deleter); } bool DateTime::operator<(const DateTime& that) const |