Fix GLFW crash when Python exits while the passive viewer is running.

Fixes #790

PiperOrigin-RevId: 549440435
Change-Id: I808f6aaab6662225e5fe1131e0da72eca6011ba9
This commit is contained in:
Saran Tunyasuvunakool
2023-07-19 15:19:44 -07:00
committed by Copybara-Service
parent 8386b28877
commit f7847ba73e
7 changed files with 192 additions and 116 deletions
+1
View File
@@ -110,6 +110,7 @@ GlfwAdapter::GlfwAdapter() {
}
GlfwAdapter::~GlfwAdapter() {
FreeMjrContext();
Glfw().glfwMakeContextCurrent(nullptr);
Glfw().glfwDestroyWindow(window_);
}
+1 -1
View File
@@ -21,7 +21,7 @@ PlatformUIAdapter::PlatformUIAdapter() {
mjr_defaultContext(&con_);
}
PlatformUIAdapter::~PlatformUIAdapter() {
void PlatformUIAdapter::FreeMjrContext() {
mjr_freeContext(&con_);
}
+3 -2
View File
@@ -22,7 +22,7 @@
namespace mujoco {
class PlatformUIAdapter {
public:
virtual ~PlatformUIAdapter();
virtual ~PlatformUIAdapter() = default;
inline mjuiState& state() { return state_; }
inline const mjuiState& state() const { return state_; }
@@ -38,7 +38,7 @@ class PlatformUIAdapter {
layout_callback_ = layout_callback;
}
// Optionally overrideable function to (re)create an mjrContext for an mjModel
// Optionally overridable function to (re)create an mjrContext for an mjModel
virtual bool RefreshMjrContext(const mjModel* m, int fontscale);
virtual bool EnsureContextSize();
@@ -73,6 +73,7 @@ class PlatformUIAdapter {
protected:
PlatformUIAdapter();
void FreeMjrContext();
// Event handlers
void OnFilesDrop(int count, const char** paths);