hoffstadt / hoffstadt/DearPyGui
Behavior of `show_viewport()` & `is_dearpygui_running()` after closing the viewport
- Dominant language
- C++
- Stars
- 15.6k
- Forks
- 783
- PR merge metrics
- No merged PRs in 30d
Description
DearPyGui v2.2
Python v3.14
Windows 11
On Windows, closing the viewport window sets `GContext->running` to `false` via `mvContext::StopRendering()`. `is_dearpygui_running()` simply returns the result of `GContext->running`, so it makes sense that it returns `False` after closing the viewport. `mvHandleMsg()` destroys the viewport on close (I *think*), but calling `show_viewport()` will display the viewport again. Doing so does not update `GContext->running`, so any code that checks against it will fail e.g. `split_frame()`. Everything else seems to work as it should. This can be reproduced with a debugger and some bare-bones code:
```python
from dearpygui import dearpygui as dpg
dpg.create_context()
dpg.setup_dearpygui()
dpg.create_viewport()
dpg.show_viewport()
while True:
dpg.render_dearpygui_frame()
```
The while-loop condition does not check `is_dearpygui_running()` and will to run after closing the viewport. Once the viewport is closed, set a breakpoint within the render loop and call `show_viewport()`. This can be done repeatedly in the same thread.
(Side node: After closing the viewport at least once, calling `show_viewport()` while the viewport is already displayed creates a "dead" viewport window.)
This behavior isn't documented and might be limited to Windows. However, I can easily see it being useful to display the viewport again once it's been closed. In its current state, many things appear to continue functioning properly, but it may have less-obvious side-effects (I don't have enough knowledge regarding DearPyGui's internals to say for certain). This issue is mostly just to make the behavior known.
Contributor guide
Assessment
This issue has not been assessed yet.