diff options
Diffstat (limited to 'weather')
-rw-r--r-- | weather/weather.cpp | 13 | ||||
-rw-r--r-- | weather/weather.h | 2 |
2 files changed, 7 insertions, 8 deletions
diff --git a/weather/weather.cpp b/weather/weather.cpp index 298f32c..d4a8173 100644 --- a/weather/weather.cpp +++ b/weather/weather.cpp @@ -21,22 +21,21 @@ #include "eventmessage.h" #include "messagefactory.h" #include "messageengine.h" +#include "messageenginefactory.h" #include "weather.h" Weather::Weather (QUrl &url, QObject * parent) : - QObject(parent), - m_mloop(nullptr) + QObject(parent) { - m_mloop = new MessageEngine(url); - QObject::connect(m_mloop, &MessageEngine::connected, this, &Weather::onConnected); - QObject::connect(m_mloop, &MessageEngine::disconnected, this, &Weather::onDisconnected); - QObject::connect(m_mloop, &MessageEngine::messageReceived, this, &Weather::onMessageReceived); + m_mloop = MessageEngineFactory::getInstance().getMessageEngine(url); + QObject::connect(m_mloop.get(), &MessageEngine::connected, this, &Weather::onConnected); + QObject::connect(m_mloop.get(), &MessageEngine::disconnected, this, &Weather::onDisconnected); + QObject::connect(m_mloop.get(), &MessageEngine::messageReceived, this, &Weather::onMessageReceived); } Weather::~Weather() { - delete m_mloop; } void Weather::onConnected() diff --git a/weather/weather.h b/weather/weather.h index 75054d5..93c5ec4 100644 --- a/weather/weather.h +++ b/weather/weather.h @@ -41,7 +41,7 @@ class Weather : public QObject void conditionChanged(QString condition); private: - MessageEngine *m_mloop; + std::shared_ptr<MessageEngine> m_mloop; QString m_temperature; QString m_condition; |