Unverified Commit fcbee10d authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

[windows] Propagate startup errors in template (#63612)

parent 337c5cfc
......@@ -8,15 +8,22 @@ FlutterWindow::FlutterWindow(RunLoop* run_loop,
FlutterWindow::~FlutterWindow() {}
void FlutterWindow::OnCreate() {
Win32Window::OnCreate();
bool FlutterWindow::OnCreate() {
if (!Win32Window::OnCreate()) {
return false;
}
// The size here is arbitrary since SetChildContent will resize it.
flutter_controller_ =
std::make_unique<flutter::FlutterViewController>(100, 100, project_);
// Ensure that basic setup of the controller was successful.
if (!flutter_controller_->engine() || !flutter_controller_->view()) {
return false;
}
RegisterPlugins(flutter_controller_.get());
run_loop_->RegisterFlutterInstance(flutter_controller_.get());
SetChildContent(flutter_controller_->view()->GetNativeWindow());
return true;
}
void FlutterWindow::OnDestroy() {
......
......@@ -20,7 +20,7 @@ class FlutterWindow : public Win32Window {
protected:
// Win32Window:
void OnCreate() override;
bool OnCreate() override;
void OnDestroy() override;
private:
......
......@@ -122,9 +122,11 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
nullptr, nullptr, GetModuleHandle(nullptr), this);
OnCreate();
if (!window) {
return false;
}
return window != nullptr;
return OnCreate();
}
// static
......@@ -240,8 +242,9 @@ void Win32Window::SetQuitOnClose(bool quit_on_close) {
quit_on_close_ = quit_on_close;
}
void Win32Window::OnCreate() {
bool Win32Window::OnCreate() {
// No-op; provided for subclasses.
return true;
}
void Win32Window::OnDestroy() {
......
......@@ -62,8 +62,8 @@ class Win32Window {
LPARAM const lparam) noexcept;
// Called when CreateAndShow is called, allowing subclass window-related
// setup.
virtual void OnCreate();
// setup. Subclasses should return false if setup fails.
virtual bool OnCreate();
// Called when Destroy is called.
virtual void OnDestroy();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment