I'm trying to use Cocoa's native window restoration with CEF. cefclient_mac.mm says:
- Code: Select all
// The default |-terminate:| implementation ends the process by calling exit(),
// and thus never leaves the main run loop. This is unsuitable for Chromium
// since Chromium depends on leaving the main run loop to perform an orderly
// shutdown.
This rules out the option of using [NSApp terminate:] directly (which causes CEF to crash in CefForceShutdown). However, in order to make window restoration work, I need to call the native implementation of [NSApp terminate:] because calling CefQuitMessageLoop() does not call my document's window:willEncodeRestorableState: method. Another option of terminating the app I was thinking about was to call [NSApp terminate:], and then override "applicationWillTerminate:" (which is called after the restoration state is serialized), and give CEF some time to clean up using CefQuitMessageLoop(); / CefDoMessageLoopWork();, however I wasn't able to come up with a working implementation.
Is there a way to use Cocoa's native [NSApp terminate:] together with CEF to enable native window restoration?
Thanks
Thomas