fix crash of closing
This commit is contained in:
parent
a4e074497f
commit
ce69c84f8a
@ -48,6 +48,10 @@ void Application::OnTimeout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::Uninit() {
|
void Application::Uninit() {
|
||||||
|
// Stop the app-level frame timer to prevent callbacks during teardown
|
||||||
|
if (timer_.isActive()) {
|
||||||
|
timer_.stop();
|
||||||
|
}
|
||||||
//Singleton<PythonModule>::Destory();
|
//Singleton<PythonModule>::Destory();
|
||||||
Singleton<NetDriver>::Destory();
|
Singleton<NetDriver>::Destory();
|
||||||
Singleton<PresetModelConfigParser>::Destory();
|
Singleton<PresetModelConfigParser>::Destory();
|
||||||
|
|||||||
@ -32,7 +32,8 @@ void EntitiesManager::OnDestory() {
|
|||||||
);
|
);
|
||||||
for (auto* entity : entities) {
|
for (auto* entity : entities) {
|
||||||
RemoveEntity(entity);
|
RemoveEntity(entity);
|
||||||
entity->deleteLater();
|
// Delete entities immediately to release scene graph resources before exit
|
||||||
|
delete entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,24 @@ void OEScene::AttachView(osgViewer::View* view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OEScene::DetachView(osgViewer::View* view) {
|
void OEScene::DetachView(osgViewer::View* view) {
|
||||||
|
if (!view) return;
|
||||||
|
|
||||||
|
// Remove sky dome from this group if present; SkyNode has no detach in osgEarth 2.8
|
||||||
|
if (skyDome_.valid()) {
|
||||||
|
removeChild(skyDome_.get());
|
||||||
|
skyDome_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear scene data
|
||||||
view->setSceneData(nullptr);
|
view->setSceneData(nullptr);
|
||||||
|
|
||||||
|
// Clear manipulator association
|
||||||
|
if (earthManipulator_.valid()) {
|
||||||
|
view->setCameraManipulator(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear internal view pointer
|
||||||
|
curentView_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OEScene::AddToScene(osg::Node* node) const {
|
bool OEScene::AddToScene(osg::Node* node) const {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "viewer/OsgWidget.h"
|
#include "viewer/OsgWidget.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
@ -69,13 +69,20 @@ OsgWidget::OsgWidget(QWidget* parent, Qt::WindowFlags f)
|
|||||||
|
|
||||||
OsgWidget::~OsgWidget() {
|
OsgWidget::~OsgWidget() {
|
||||||
LOG_INFO("OsgWidget::~OsgWidget");
|
LOG_INFO("OsgWidget::~OsgWidget");
|
||||||
|
// Stop periodic updates to prevent callbacks during teardown
|
||||||
|
if (timer_.isActive()) {
|
||||||
|
timer_.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// First unload the workspace while scene/view are still valid,
|
||||||
|
// so entities can detach cleanly from the scene graph
|
||||||
if (nullptr != workspace_) {
|
if (nullptr != workspace_) {
|
||||||
workspace_->Unlaod();
|
workspace_->Unlaod();
|
||||||
|
workspace_ = nullptr;
|
||||||
}
|
}
|
||||||
if (nullptr != viewUI_) {
|
|
||||||
viewUI_->RemoveUI(activeScene_->GetOrCreateSceneUI());
|
// Then perform the viewer teardown (detach UI, view, and scene)
|
||||||
viewUI_ = nullptr;
|
Uninitialize();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgWidget::Initialize() {
|
void OsgWidget::Initialize() {
|
||||||
|
|||||||
@ -21,6 +21,16 @@ WorkSpaceManager::~WorkSpaceManager() {
|
|||||||
|
|
||||||
void WorkSpaceManager::OnDestory() {
|
void WorkSpaceManager::OnDestory() {
|
||||||
SaveDefaultWorkspace();
|
SaveDefaultWorkspace();
|
||||||
|
for (auto& kv : workSpaces_) {
|
||||||
|
WorkSpace* ws = kv.second;
|
||||||
|
if (ws) {
|
||||||
|
ws->Unlaod();
|
||||||
|
ws->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
workSpaces_.clear();
|
||||||
|
|
||||||
|
scene_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* WorkSpaceManager::LoadDefaultWorkspace(class OEScene* secen) {
|
WorkSpace* WorkSpaceManager::LoadDefaultWorkspace(class OEScene* secen) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user