mirror of https://github.com/nymea/nymea.git
Prevent multiple finish calls on API objects
Bad plugin implementations might call finish() more than once which is not expected by receivers of the finished() signal and may cause weird side effects.pull/370/head
parent
c31b99b04e
commit
a11a219bbf
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
BrowserActionInfo::BrowserActionInfo(Thing *thing, ThingManager *thingManager, const BrowserAction &browserAction, QObject *parent, quint32 timeout):
|
||||
QObject (parent),
|
||||
m_thing(thing),
|
||||
|
|
@ -85,6 +87,10 @@ QString BrowserActionInfo::translatedDisplayMessage(const QLocale &locale)
|
|||
|
||||
void BrowserActionInfo::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "BrowserActionInfo::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
BrowseResult::BrowseResult(Thing *thing, ThingManager *thingManager, const QString &itemId, const QLocale &locale, QObject *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_thing(thing),
|
||||
|
|
@ -106,6 +108,10 @@ void BrowseResult::addItems(const BrowserItems &items)
|
|||
|
||||
void BrowseResult::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "BrowseResult::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
BrowserItemActionInfo::BrowserItemActionInfo(Thing *thing, ThingManager *thingManager, const BrowserItemAction &browserItemAction, QObject *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_thing(thing),
|
||||
|
|
@ -85,6 +87,10 @@ QString BrowserItemActionInfo::translatedDisplayMessage(const QLocale &locale)
|
|||
|
||||
void BrowserItemActionInfo::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "BrowserItemActionInfo::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
BrowserItemResult::BrowserItemResult(Thing *thing, ThingManager *thingManager, const QString &itemId, const QLocale &locale, QObject *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_thing(thing),
|
||||
|
|
@ -102,6 +104,10 @@ void BrowserItemResult::finish(const BrowserItem &item)
|
|||
|
||||
void BrowserItemResult::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "BrowserItemResult::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
ThingActionInfo::ThingActionInfo(Thing *thing, const Action &action, ThingManager *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_thing(thing),
|
||||
|
|
@ -85,6 +87,10 @@ QString ThingActionInfo::translatedDisplayMessage(const QLocale &locale)
|
|||
|
||||
void ThingActionInfo::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "ThingActionInfo::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
ThingDiscoveryInfo::ThingDiscoveryInfo(const ThingClassId &thingClassId, const ParamList ¶ms, ThingManager *thingManager, quint32 timeout):
|
||||
QObject(thingManager),
|
||||
m_thingClassId(thingClassId),
|
||||
|
|
@ -100,6 +102,10 @@ QString ThingDiscoveryInfo::translatedDisplayMessage(const QLocale &locale)
|
|||
|
||||
void ThingDiscoveryInfo::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "ThingDiscoveryInfo::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
ThingPairingInfo::ThingPairingInfo(const PairingTransactionId &pairingTransactionId, const ThingClassId &thingClassId, const ThingId &thingId, const QString &deviceName, const ParamList ¶ms, const ThingId &parentId, ThingManager *parent, quint32 timeout):
|
||||
QObject(parent),
|
||||
m_transactionId(pairingTransactionId),
|
||||
|
|
@ -113,6 +115,10 @@ QString ThingPairingInfo::translatedDisplayMessage(const QLocale &locale) const
|
|||
|
||||
void ThingPairingInfo::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "ThingPairingInfo::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcIntegrations)
|
||||
|
||||
ThingSetupInfo::ThingSetupInfo(Thing *thing, ThingManager *thingManager, quint32 timeout):
|
||||
QObject(thingManager),
|
||||
m_thing(thing),
|
||||
|
|
@ -81,6 +83,10 @@ QString ThingSetupInfo::translatedDisplayMessage(const QLocale &locale)
|
|||
|
||||
void ThingSetupInfo::finish(Thing::ThingError status, const QString &displayMessage)
|
||||
{
|
||||
if (m_finished) {
|
||||
qCWarning(dcIntegrations()) << "ThingSetupInfo::finish() called on an already finished object.";
|
||||
return;
|
||||
}
|
||||
m_finished = true;
|
||||
m_status = status;
|
||||
m_displayMessage = displayMessage;
|
||||
|
|
|
|||
Loading…
Reference in New Issue