mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 18:44:00 +02:00
properly hook SharedNodePointer for signals/slots
This commit is contained in:
parent
7d1a64ca8c
commit
677303b5c0
3 changed files with 9 additions and 4 deletions
|
@ -25,7 +25,8 @@
|
|||
#include "NodeData.h"
|
||||
#include "SimpleMovingAverage.h"
|
||||
|
||||
class Node {
|
||||
class Node : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket);
|
||||
~Node();
|
||||
|
|
|
@ -36,6 +36,9 @@ NodeList* NodeList::_sharedInstance = NULL;
|
|||
NodeList* NodeList::createInstance(char ownerType, unsigned short int socketListenPort) {
|
||||
if (!_sharedInstance) {
|
||||
_sharedInstance = new NodeList(ownerType, socketListenPort);
|
||||
|
||||
// register the SharedNodePointer meta-type for signals/slots
|
||||
qRegisterMetaType<SharedNodePointer>();
|
||||
} else {
|
||||
qDebug("NodeList createInstance called with existing instance.");
|
||||
}
|
||||
|
@ -682,7 +685,7 @@ SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
|||
// we didn't have this node, so add them
|
||||
Node* newNode = new Node(uuid, nodeType, publicSocket, localSocket);
|
||||
|
||||
NodeHash::iterator addedItem = _nodeHash.insert(newNode->getUUID(), SharedNodePointer(newNode));
|
||||
NodeHash::iterator addedItem = _nodeHash.insert(newNode->getUUID(), SharedNodePointer(newNode, &QObject::deleteLater));
|
||||
|
||||
qDebug() << "Added" << *newNode << "\n";
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
|
||||
typedef QSharedPointer<Node> SharedNodePointer;
|
||||
typedef QHash<QUuid, SharedNodePointer> NodeHash;
|
||||
Q_DECLARE_METATYPE(SharedNodePointer)
|
||||
|
||||
class NodeList : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -128,8 +129,8 @@ public slots:
|
|||
void pingInactiveNodes();
|
||||
void removeSilentNodes();
|
||||
signals:
|
||||
void nodeAdded(QSharedPointer<Node>);
|
||||
void nodeKilled(QSharedPointer<Node>);
|
||||
void nodeAdded(SharedNodePointer);
|
||||
void nodeKilled(SharedNodePointer);
|
||||
private:
|
||||
static NodeList* _sharedInstance;
|
||||
|
||||
|
|
Loading…
Reference in a new issue