summaryrefslogtreecommitdiffstats
path: root/navigation
diff options
context:
space:
mode:
Diffstat (limited to 'navigation')
-rw-r--r--navigation/navigation.cpp13
-rw-r--r--navigation/navigation.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/navigation/navigation.cpp b/navigation/navigation.cpp
index e0078c2..e24df1a 100644
--- a/navigation/navigation.cpp
+++ b/navigation/navigation.cpp
@@ -20,22 +20,21 @@
#include "eventmessage.h"
#include "messagefactory.h"
#include "messageengine.h"
+#include "messageenginefactory.h"
#include "navigation.h"
Navigation::Navigation (QUrl &url, QObject * parent) :
- QObject(parent),
- m_mloop(nullptr)
+ QObject(parent)
{
- m_mloop = new MessageEngine(url);
- QObject::connect(m_mloop, &MessageEngine::connected, this, &Navigation::onConnected);
- QObject::connect(m_mloop, &MessageEngine::disconnected, this, &Navigation::onDisconnected);
- QObject::connect(m_mloop, &MessageEngine::messageReceived, this, &Navigation::onMessageReceived);
+ m_mloop = MessageEngineFactory::getInstance().getMessageEngine(url);
+ QObject::connect(m_mloop.get(), &MessageEngine::connected, this, &Navigation::onConnected);
+ QObject::connect(m_mloop.get(), &MessageEngine::disconnected, this, &Navigation::onDisconnected);
+ QObject::connect(m_mloop.get(), &MessageEngine::messageReceived, this, &Navigation::onMessageReceived);
}
Navigation::~Navigation()
{
- delete m_mloop;
}
void Navigation::sendWaypoint(double lat, double lon)
diff --git a/navigation/navigation.h b/navigation/navigation.h
index 87e5636..b1c0412 100644
--- a/navigation/navigation.h
+++ b/navigation/navigation.h
@@ -46,7 +46,7 @@ class Navigation : public QObject
void waypointsEvent(QVariantMap data);
private:
- MessageEngine *m_mloop;
+ std::shared_ptr<MessageEngine> m_mloop;
// slots
void onMessageReceived(std::shared_ptr<Message> msg);