X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fsyncableobject.cpp;fp=src%2Fcommon%2Fsyncableobject.cpp;h=695ab913a74bec6c8b87d03d5be72b9e419d731c;hp=9fd7704f0122d29154ebb3c0f38b07c8b7382e91;hb=b8ce41ef6c0036d854f5bef0fb52e2a69dc5def2;hpb=96e623bcd9a56fdf153a6c82376a9ab0c45aa102 diff --git a/src/common/syncableobject.cpp b/src/common/syncableobject.cpp index 9fd7704f..695ab913 100644 --- a/src/common/syncableobject.cpp +++ b/src/common/syncableobject.cpp @@ -27,20 +27,29 @@ #include "util.h" SyncableObject::SyncableObject(QObject* parent) - : QObject(parent) + : SyncableObject(QString{}, parent) {} SyncableObject::SyncableObject(const QString& objectName, QObject* parent) : QObject(parent) { + _objectName = objectName; setObjectName(objectName); + + connect(this, &QObject::objectNameChanged, this, [this](auto&& newName) { + for (auto&& proxy : _signalProxies) { + proxy->renameObject(this, newName, _objectName); + } + _objectName = newName; + }); } SyncableObject::SyncableObject(const SyncableObject& other, QObject* parent) - : QObject(parent) - , _initialized(other._initialized) - , _allowClientUpdates(other._allowClientUpdates) -{} + : SyncableObject(QString{}, parent) +{ + _initialized = other._initialized; + _allowClientUpdates = other._allowClientUpdates; +} SyncableObject::~SyncableObject() { @@ -156,17 +165,6 @@ bool SyncableObject::setInitValue(const QString& property, const QVariant& value return QMetaObject::invokeMethod(this, handlername.toLatin1(), param); } -void SyncableObject::renameObject(const QString& newName) -{ - const QString oldName = objectName(); - if (oldName != newName) { - setObjectName(newName); - foreach (SignalProxy* proxy, _signalProxies) { - proxy->renameObject(this, newName, oldName); - } - } -} - void SyncableObject::update(const QVariantMap& properties) { fromVariantMap(properties);