Don't connect to QObject::objectNameChanged
Connect to the view's signal instead. Decouples a bit more from QObject
This commit is contained in:
@@ -32,5 +32,9 @@ public:
|
||||
|
||||
/// @brief signal emitted when the view's parent has changed
|
||||
KDBindings::Signal<> parentChanged;
|
||||
|
||||
/// @brief signal emitted when the view's debug name has changed
|
||||
/// Used for debug only
|
||||
KDBindings::Signal<> debugNameChanged;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ void Item::setGuestView(View *guest)
|
||||
|
||||
m_guest = guest;
|
||||
m_parentChangedConnection->disconnect();
|
||||
m_guestDebugNameChangedConnection->disconnect();
|
||||
|
||||
if (m_guest) {
|
||||
m_guest->setParent(m_hostWidget);
|
||||
@@ -205,7 +206,8 @@ void Item::setGuestView(View *guest)
|
||||
setMaxSizeHint(guest->maxSizeHint());
|
||||
}
|
||||
|
||||
connect(newWidget, &QObject::objectNameChanged, this, &Item::updateObjectName);
|
||||
m_guestDebugNameChangedConnection = m_guest->d->debugNameChanged.connect(&Item::updateObjectName, this);
|
||||
|
||||
connect(newWidget, &QObject::destroyed, this, &Item::onWidgetDestroyed);
|
||||
|
||||
m_layoutInvalidatedConnection->disconnect();
|
||||
@@ -805,6 +807,7 @@ void Item::onWidgetDestroyed()
|
||||
{
|
||||
m_guest = nullptr;
|
||||
m_parentChangedConnection->disconnect();
|
||||
m_guestDebugNameChangedConnection->disconnect();
|
||||
|
||||
if (m_refCount) {
|
||||
turnIntoPlaceholder();
|
||||
|
||||
@@ -393,6 +393,7 @@ private:
|
||||
KDBindings::ConnectionHandle m_visibleChangedHandle;
|
||||
KDBindings::ScopedConnection m_layoutInvalidatedConnection;
|
||||
KDBindings::ScopedConnection m_parentChangedConnection;
|
||||
KDBindings::ScopedConnection m_guestDebugNameChangedConnection;
|
||||
};
|
||||
|
||||
/// @brief And Item which can contain other Items
|
||||
|
||||
@@ -55,8 +55,10 @@ QObject *View_qt::thisObject() const
|
||||
|
||||
void View_qt::setObjectName(const QString &name)
|
||||
{
|
||||
if (m_thisObj)
|
||||
if (m_thisObj) {
|
||||
m_thisObj->setObjectName(name);
|
||||
d->debugNameChanged.emit();
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/
|
||||
|
||||
Reference in New Issue
Block a user