diff --git a/powerdevil/daemon/powerdevilactionpool.cpp b/powerdevil/daemon/powerdevilactionpool.cpp
index 970aa18..6ca0d57 100644
--- a/powerdevil/daemon/powerdevilactionpool.cpp
+++ b/powerdevil/daemon/powerdevilactionpool.cpp
@@ -82,6 +82,7 @@ void ActionPool::clearCache()
i.value()->deleteLater();
i = m_actionPool.erase(i);
}
+ m_initErrors.clear();
}
void ActionPool::init(PowerDevil::Core *parent)
@@ -99,6 +100,7 @@ void ActionPool::init(PowerDevil::Core *parent)
if (!retaction) {
// Troubles...
kWarning() << "failed to load" << offer->desktopEntryName();
+ m_initErrors.insert(actionId, LoadFailed);
continue;
}
@@ -106,6 +108,7 @@ void ActionPool::init(PowerDevil::Core *parent)
if (!retaction->isSupported()) {
// Skip that
retaction->deleteLater();
+ m_initErrors.insert(actionId, NotSupported);
continue;
}
@@ -169,7 +172,13 @@ Action* ActionPool::loadAction(const QString& actionId, const KConfigGroup& grou
return retaction;
} else {
- // Hmm... troubles in configuration. Np, let's just return 0 and let the core handle this
+ // may be a misconfiguration.
+ // Set the error code and return 0 and let the caller handle this as it sees fit
+ if (m_initErrors.contains(actionId)) {
+ m_error = m_initErrors[actionId];
+ } else { // no error recorded during initialisation, therefore action does not exist
+ m_error = NoAction;
+ }
return 0;
}
}
@@ -183,4 +192,9 @@ void ActionPool::unloadAllActiveActions()
m_activeActions.clear();
}
+ActionPool::ErrorCode ActionPool::error()
+{
+ return m_error;
+}
+
}
diff --git a/powerdevil/daemon/powerdevilactionpool.h b/powerdevil/daemon/powerdevilactionpool.h
index ca436ff..816449e 100644
--- a/powerdevil/daemon/powerdevilactionpool.h
+++ b/powerdevil/daemon/powerdevilactionpool.h
@@ -36,6 +36,11 @@ class Action;
class KDE_EXPORT ActionPool
{
public:
+ enum ErrorCode {
+ NoAction,
+ LoadFailed,
+ NotSupported
+ };
static ActionPool *instance();
virtual ~ActionPool();
@@ -48,11 +53,15 @@ public:
void clearCache();
+ ErrorCode error();
+
private:
ActionPool();
QHash< QString, Action* > m_actionPool;
QStringList m_activeActions;
+ ErrorCode m_error;
+ QHash< QString, ErrorCode > m_initErrors;
};
}
diff --git a/powerdevil/daemon/powerdevilcore.cpp b/powerdevil/daemon/powerdevilcore.cpp
index d096d74..c35b29d 100644
--- a/powerdevil/daemon/powerdevilcore.cpp
+++ b/powerdevil/daemon/powerdevilcore.cpp
@@ -357,11 +357,23 @@ void Core::loadProfile(bool force)
if (action) {
action->onProfileLoad();
} else {
- // Ouch, error. But let's just warn and move on anyway
- //TODO Maybe Remove from the configuration if unsupported
- kWarning() << "The profile " << profileId << "tried to activate"
- << actionName << "a non existent action. This is usually due to an installation problem"
- " or to a configuration problem. or simlpy the action is not supported";
+ switch (ActionPool::instance()->error()) {
+ case ActionPool::NotSupported:
+ kWarning().nospace() << "Attempted to load unsupported action " << actionName
+ << ", skipping";
+ break;
+ case ActionPool::LoadFailed:
+ kWarning() << "Action" << actionName << "failed during initialisation";
+ // fallthrough
+ case ActionPool::NoAction:
+ default:
+ // Ouch, error. But let's just warn and move on anyway
+ //TODO Maybe Remove from the configuration if unsupported
+ kWarning() << "The profile " << profileId << "tried to activate"
+ << actionName << "a non existent action. This is usually due to an installation problem"
+ " or to a configuration problem. or simlpy the action is not supported";
+ break;
+ }
}
}