fix crash of closing
This commit is contained in:
parent
a4e074497f
commit
ce69c84f8a
@ -48,6 +48,10 @@ void Application::OnTimeout() {
|
||||
}
|
||||
|
||||
void Application::Uninit() {
|
||||
// Stop the app-level frame timer to prevent callbacks during teardown
|
||||
if (timer_.isActive()) {
|
||||
timer_.stop();
|
||||
}
|
||||
//Singleton<PythonModule>::Destory();
|
||||
Singleton<NetDriver>::Destory();
|
||||
Singleton<PresetModelConfigParser>::Destory();
|
||||
|
||||
@ -32,7 +32,8 @@ void EntitiesManager::OnDestory() {
|
||||
);
|
||||
for (auto* entity : entities) {
|
||||
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) {
|
||||
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);
|
||||
|
||||
// Clear manipulator association
|
||||
if (earthManipulator_.valid()) {
|
||||
view->setCameraManipulator(nullptr);
|
||||
}
|
||||
|
||||
// Clear internal view pointer
|
||||
curentView_ = nullptr;
|
||||
}
|
||||
|
||||
bool OEScene::AddToScene(osg::Node* node) const {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "viewer/OsgWidget.h"
|
||||
#include "viewer/OsgWidget.h"
|
||||
|
||||
|
||||
#include <QWindow>
|
||||
@ -69,13 +69,20 @@ OsgWidget::OsgWidget(QWidget* parent, Qt::WindowFlags f)
|
||||
|
||||
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_) {
|
||||
workspace_->Unlaod();
|
||||
workspace_ = nullptr;
|
||||
}
|
||||
if (nullptr != viewUI_) {
|
||||
viewUI_->RemoveUI(activeScene_->GetOrCreateSceneUI());
|
||||
viewUI_ = nullptr;
|
||||
}
|
||||
|
||||
// Then perform the viewer teardown (detach UI, view, and scene)
|
||||
Uninitialize();
|
||||
}
|
||||
|
||||
void OsgWidget::Initialize() {
|
||||
|
||||
@ -21,6 +21,16 @@ WorkSpaceManager::~WorkSpaceManager() {
|
||||
|
||||
void WorkSpaceManager::OnDestory() {
|
||||
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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user