-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI: Add obs_frontend_close_main_window() #8889
base: master
Are you sure you want to change the base?
Conversation
Is this supposed to end the application? Because on macOS an application is not automatically terminated just because it has no active windows - that’s an opt-in behaviour. It could be that Qt behaves this way in our case, but that needs to be verified. |
For the use case that I'm targeting, yes, the intention is to end the application. I just tested the release version of OBS on macOS, and indeed, clicking the Exit button and closing the window both end the application. |
Our main window's close event handler does some cleanup and ultimately calls obs-studio/UI/window-basic-main.cpp Line 5042 in c289efd
|
0ef1e34
to
d534669
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'd like us to include a log line indicating when something has closed OBS this way. How does this interact with things that prevent closing the window such as running outputs? |
"Closes the main window. If there are active outputs, the user will be prompted to confirm before closing." |
3cc2020
to
b3316e2
Compare
Adds the ability to close the main window from the frontend API. The behaviour is the same as clicking the Exit button in OBS Studio.
b3316e2
to
a841c9f
Compare
@Warchamp7 Log line added.
This was answered in the next comment. Let me know if you have any more questions/issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine from my end with the log line added
Description
Adds the ability to close the main window from the frontend API. The behaviour is the same as clicking the Exit button in OBS Studio.
Motivation and Context
This is useful for scripting, where OBS is mainly run from the system tray and controlled through the script, i.e. through obs-websocket. Currently, the only way to close OBS from a script is to have the OS terminate the process. This is obviously not ideal: the program doesn't get the chance to properly free up resources, and in the case of Windows, the icon hangs around the system tray until it is moused-over.
Link to feature suggestion: https://ideas.obsproject.com/posts/2225/allow-clean-shutdown-via-api
How Has This Been Tested?
OS: Windows
CPU: Intel i7 12700K
GPU: Gigabyte Nvidia GeForce RTX 3070 Ti 8 GB
RAM: 32GB
For the sake of simplicity, I hijacked the
StartStream
handler of obs-websocket to instead callobs_frontend_close_main_window()
, then used OBS-web to trigger the handler. The OBS Studio window closed, and the log indicated that the shutdown process completed nominally, just as it would have if the Exit button was clicked.Types of changes
Checklist: