Skip to content

Commit 513ba95

Browse files
committed
fix: remove redundant setParent call in NetItemPrivate
The code was calling setParent on the newly created NetItem object with its private implementation as the parent. This is unnecessary and likely incorrect since the private implementation is not a QObject. The parent- child relationship in Qt should be between QObjects, and NetItemPrivate is not a QObject subclass. This was causing compilation errors due to type mismatch in the setParent call. The fix removes the redundant setParent call which was attempting to set a non-QObject as parent. The NetItem object should manage its own parent relationships separately if needed, not through its private implementation class. Influence: 1. Verify that NetItem objects are still properly created and initialized 2. Test that parent-child relationships work correctly when NetItem objects need them 3. Ensure no memory leaks occur due to missing parent relationships 4. Test that all NetItem subclasses (NetType, etc.) compile and work correctly fix: 移除NetItemPrivate中冗余的setParent调用 代码在新建NetItem对象时尝试将其父对象设置为私有实现类,这是不必要且错误 的,因为私有实现类不是QObject。Qt中的父子关系应该存在于QObject之间,而 NetItemPrivate不是QObject的子类。这导致了setParent调用中的类型不匹配编译 错误。 修复移除了冗余的setParent调用,该调用试图将非QObject对象设置为父对象。 NetItem对象如果需要父子关系,应该单独管理,而不是通过其私有实现类。 Influence: 1. 验证NetItem对象仍能正确创建和初始化 2. 测试当NetItem对象需要父子关系时,这些关系能正常工作 3. 确保不会因缺少父子关系而导致内存泄漏 4. 测试所有NetItem子类(NetType等)都能正确编译和工作
1 parent d5e89e0 commit 513ba95

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

net-view/operation/private/netitemprivate.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ NetItemPrivate::~NetItemPrivate()
4949
case NetType::Type: \
5050
netItemPrivate = new Net##Type##Private(); \
5151
netItemPrivate->m_item = new Net##Type(netItemPrivate, id); \
52-
netItemPrivate->m_item->setParent(netItemPrivate); \
5352
break
5453

5554
NetItemPrivate *NetItemPrivate::New(NetType::NetItemType type, const QString &id)

0 commit comments

Comments
 (0)