Skip to content

Commit 8c38401

Browse files
authored
quit cleanly by calling destory explicitly (#174)
1 parent 0e42dbb commit 8c38401

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/python/guik.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void define_guik(py::module_& m) {
287287
py::class_<guik::ProjectionControl, std::shared_ptr<guik::ProjectionControl>>(guik_, "ProjectionControl");
288288

289289
// guik::Application
290-
py::class_<guik::Application>(guik_, "Application")
290+
py::class_<guik::Application, std::unique_ptr<guik::Application, py::nodelete>>(guik_, "Application")
291291
.def("ok", &guik::Application::ok)
292292
.def("enable_vsync", &guik::Application::enable_vsync)
293293
.def("disable_vsync", &guik::Application::disable_vsync)
@@ -886,4 +886,10 @@ void define_guik(py::module_& m) {
886886
py::arg("title") = "screen");
887887
guik_.def("async_destroy", &guik::async_destroy, "");
888888
guik_.def("async_wait", &guik::async_wait, "");
889+
890+
auto atexit = py::module_::import("atexit");
891+
atexit.attr("register")(py::cpp_function([]() {
892+
guik::async_destroy();
893+
guik::destroy();
894+
}));
889895
}

0 commit comments

Comments
 (0)