mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
framework: fix pview crash when exit is called inside render_frame
This can happen when a system event (eg. on macOS) triggers a terminate from within process_events. This is a workaround for a common error; the proper fix is not to put PandaFramework in the global scope.
This commit is contained in:
parent
4eb250cb87
commit
63b1e44977
@ -1391,11 +1391,17 @@ AsyncTask::DoneStatus PandaFramework::
|
||||
task_igloop(GenericAsyncTask *task, void *data) {
|
||||
PandaFramework *self = (PandaFramework *)data;
|
||||
|
||||
if (self->_engine != (GraphicsEngine *)NULL) {
|
||||
self->_engine->render_frame();
|
||||
}
|
||||
|
||||
// This exists to work around a crash that happens when the PandaFramework
|
||||
// is destructed because the application is exited during render_frame().
|
||||
// The proper fix is not to instantiate PandaFramework in the global scope
|
||||
// but many C++ applications (including pview) do this anyway.
|
||||
PT(GraphicsEngine) engine = self->_engine;
|
||||
if (engine != nullptr) {
|
||||
engine->render_frame();
|
||||
return AsyncTask::DS_cont;
|
||||
} else {
|
||||
return AsyncTask::DS_done;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user