更新UI
This commit is contained in:
@@ -40,37 +40,25 @@ ObjLoader::ObjLoader(QObject *parent)
|
||||
*/
|
||||
ObjLoader::~ObjLoader()
|
||||
{
|
||||
// 1. 先销毁所有子模型(避免父模型先销毁导致子模型悬空)
|
||||
QVector<QString> childDeviceNames;
|
||||
for (const auto& device : m_deviceMap) {
|
||||
if (!device.parentDeviceName.isEmpty()) {
|
||||
childDeviceNames.append(device.name);
|
||||
}
|
||||
}
|
||||
for (const auto& childName : childDeviceNames) {
|
||||
auto it = m_deviceMap.find(childName);
|
||||
if (it != m_deviceMap.end()) {
|
||||
delete it->modelTransform;
|
||||
delete it->transform;
|
||||
delete it->modelEntity;
|
||||
delete it->entity;
|
||||
m_deviceMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 再销毁父模型
|
||||
for (auto &device : m_deviceMap) {
|
||||
delete device.modelTransform;
|
||||
delete device.transform;
|
||||
delete device.modelEntity;
|
||||
delete device.entity;
|
||||
// 安全清理:避免双重删除和悬空指针
|
||||
|
||||
// 1. 停止动画定时器
|
||||
if (m_animTimer) {
|
||||
m_animTimer->stop();
|
||||
m_animTimer->deleteLater();
|
||||
m_animTimer = nullptr;
|
||||
}
|
||||
|
||||
// 2. 清理设备映射表(Qt3D对象由Qt框架自动管理,不要手动delete)
|
||||
m_deviceMap.clear();
|
||||
|
||||
// 3. 清理场景资源
|
||||
delete m_wholeModelEntity;
|
||||
delete m_rootEntity;
|
||||
delete m_3dView;
|
||||
|
||||
// 3. 清理场景资源(设置为nullptr,Qt框架会自动管理)
|
||||
m_wholeModelEntity = nullptr;
|
||||
m_rootEntity = nullptr;
|
||||
|
||||
// 4. 3D窗口由Qt容器管理,不要手动删除
|
||||
m_3dView = nullptr;
|
||||
m_viewContainer = nullptr;
|
||||
}
|
||||
/**
|
||||
* @brief ObjLoader::setEnDebug 是否启用qDebug打印信息
|
||||
|
||||
Reference in New Issue
Block a user