From 608a1be3d492bfdcda5553558836495f7dd04645 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Wed, 8 Jul 2015 12:21:20 +0200 Subject: [PATCH] doc and some asserts --- src/libsnore/application.cpp | 5 ++++- src/libsnore/application.h | 3 ++- src/libsnore/snore.cpp | 18 +++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libsnore/application.cpp b/src/libsnore/application.cpp index 1bc9196..37f3ec6 100644 --- a/src/libsnore/application.cpp +++ b/src/libsnore/application.cpp @@ -18,13 +18,14 @@ #include "application.h" #include "application_p.h" +#include "snore_p.h" #include using namespace Snore; Application::Application(): - d(NULL) + d(nullptr) {} Application::Application(const QString &name, const Icon &icon) : @@ -52,6 +53,8 @@ Application::~Application() void Application::addAlert(const Alert &alert) { + Q_ASSERT_X(!SnoreCore::instance().aplications().contains(name()), Q_FUNC_INFO, + "Alerts must be added before the application is Registered." ); d->m_alerts.insert(alert.name().toUtf8(), alert); } diff --git a/src/libsnore/application.h b/src/libsnore/application.h index 3057364..a4c5786 100644 --- a/src/libsnore/application.h +++ b/src/libsnore/application.h @@ -64,7 +64,8 @@ public: ~Application(); /** - * Add an alert to the Application + * Add an alert to the Application. + * Alerts must be added before the application is registered. * @param alert the Alert */ void addAlert(const Alert &alert); diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index c136633..903bdbf 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -92,7 +92,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) } } } - break; + break; default: snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type(); continue; @@ -114,10 +114,6 @@ void SnoreCore::broadcastNotification(Notification notification) { Q_D(SnoreCore); Q_ASSERT_X(!notification.data()->isBroadcasted(), Q_FUNC_INFO, "Notification was already broadcasted."); - if (notification.data()->isBroadcasted()) { - snoreDebug(SNORE_WARNING) << "Notification" << notification << "was already broadcasted."; - return; - } snoreDebug(SNORE_DEBUG) << "Broadcasting" << notification << "timeout:" << notification.timeout(); if (d->m_notificationBackend != nullptr) { if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) { @@ -131,11 +127,11 @@ void SnoreCore::broadcastNotification(Notification notification) void SnoreCore::registerApplication(const Application &application) { Q_D(SnoreCore); - if (!d->m_applications.contains(application.name())) { - snoreDebug(SNORE_DEBUG) << "Registering Application:" << application; - d->m_applications.insert(application.name(), application); - emit d->applicationRegistered(application); - } + Q_ASSERT_X(!d->m_applications.contains(application.name()), Q_FUNC_INFO, + "Applications mus be registered only once."); + snoreDebug(SNORE_DEBUG) << "Registering Application:" << application; + d->m_applications.insert(application.name(), application); + emit d->applicationRegistered(application); } void SnoreCore::deregisterApplication(const Application &application) @@ -246,7 +242,7 @@ void SnoreCore::displayExapleNotification() { Application app = SnoreCorePrivate::instance()->defaultApplication(); QString text = QLatin1String("") + tr("This is Snore") + QLatin1String("
") + - QLatin1String("") + tr("Project Website") + QLatin1String("
"); + QLatin1String("") + tr("Project Website") + QLatin1String("
"); if (!app.constHints().value("use-markup").toBool()) { text = Utils::normalizeMarkup(text, Utils::NO_MARKUP); }