Add a method to flutter_window_controller to destroy the current window. (flutter/engine#12076)
This allows the embedder to be shutdown by means other than manually closing the window (e.g. by handling a SIGINT).
This commit is contained in:
committed by
stuartmorgan
parent
67552b48d9
commit
1ebef447d7
@@ -68,6 +68,14 @@ bool FlutterWindowController::CreateWindow(
|
||||
return true;
|
||||
}
|
||||
|
||||
void FlutterWindowController::DestroyWindow() {
|
||||
if (controller_) {
|
||||
FlutterDesktopDestroyWindow(controller_);
|
||||
controller_ = nullptr;
|
||||
window_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
FlutterDesktopPluginRegistrarRef FlutterWindowController::GetRegistrarForPlugin(
|
||||
const std::string& plugin_name) {
|
||||
if (!controller_) {
|
||||
@@ -99,9 +107,7 @@ bool FlutterWindowController::RunEventLoopWithTimeout(
|
||||
bool still_running = FlutterDesktopRunWindowEventLoopWithTimeout(
|
||||
controller_, timeout_milliseconds);
|
||||
if (!still_running) {
|
||||
FlutterDesktopDestroyWindow(controller_);
|
||||
window_ = nullptr;
|
||||
controller_ = nullptr;
|
||||
DestroyWindow();
|
||||
}
|
||||
return still_running;
|
||||
}
|
||||
|
||||
@@ -69,8 +69,15 @@ class FlutterWindowController : public PluginRegistry {
|
||||
const std::string& assets_path,
|
||||
const std::vector<std::string>& arguments);
|
||||
|
||||
// Destroys the current window, if any.
|
||||
//
|
||||
// Because only one window can exist at a time, this method must be called
|
||||
// between calls to CreateWindow, or the second one will fail.
|
||||
void DestroyWindow();
|
||||
|
||||
// The FlutterWindow managed by this controller, if any. Returns nullptr
|
||||
// before CreateWindow is called, and after RunEventLoop returns;
|
||||
// before CreateWindow is called, after DestroyWindow is called, and after
|
||||
// RunEventLoop returns;
|
||||
FlutterWindow* window() { return window_.get(); }
|
||||
|
||||
// Processes the next event on this window, or returns early if |timeout| is
|
||||
|
||||
Reference in New Issue
Block a user