mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[windows] Propagate startup errors in template (#63612)
This commit is contained in:
parent
337c5cfc52
commit
fcbee10da9
@ -8,15 +8,22 @@ FlutterWindow::FlutterWindow(RunLoop* run_loop,
|
|||||||
|
|
||||||
FlutterWindow::~FlutterWindow() {}
|
FlutterWindow::~FlutterWindow() {}
|
||||||
|
|
||||||
void FlutterWindow::OnCreate() {
|
bool FlutterWindow::OnCreate() {
|
||||||
Win32Window::OnCreate();
|
if (!Win32Window::OnCreate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// The size here is arbitrary since SetChildContent will resize it.
|
// The size here is arbitrary since SetChildContent will resize it.
|
||||||
flutter_controller_ =
|
flutter_controller_ =
|
||||||
std::make_unique<flutter::FlutterViewController>(100, 100, project_);
|
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());
|
RegisterPlugins(flutter_controller_.get());
|
||||||
run_loop_->RegisterFlutterInstance(flutter_controller_.get());
|
run_loop_->RegisterFlutterInstance(flutter_controller_.get());
|
||||||
SetChildContent(flutter_controller_->view()->GetNativeWindow());
|
SetChildContent(flutter_controller_->view()->GetNativeWindow());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlutterWindow::OnDestroy() {
|
void FlutterWindow::OnDestroy() {
|
||||||
|
@ -20,7 +20,7 @@ class FlutterWindow : public Win32Window {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Win32Window:
|
// Win32Window:
|
||||||
void OnCreate() override;
|
bool OnCreate() override;
|
||||||
void OnDestroy() override;
|
void OnDestroy() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -122,9 +122,11 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
|||||||
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
|
||||||
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
nullptr, nullptr, GetModuleHandle(nullptr), this);
|
||||||
|
|
||||||
OnCreate();
|
if (!window) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return window != nullptr;
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -240,8 +242,9 @@ void Win32Window::SetQuitOnClose(bool quit_on_close) {
|
|||||||
quit_on_close_ = quit_on_close;
|
quit_on_close_ = quit_on_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::OnCreate() {
|
bool Win32Window::OnCreate() {
|
||||||
// No-op; provided for subclasses.
|
// No-op; provided for subclasses.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Window::OnDestroy() {
|
void Win32Window::OnDestroy() {
|
||||||
|
@ -62,8 +62,8 @@ class Win32Window {
|
|||||||
LPARAM const lparam) noexcept;
|
LPARAM const lparam) noexcept;
|
||||||
|
|
||||||
// Called when CreateAndShow is called, allowing subclass window-related
|
// Called when CreateAndShow is called, allowing subclass window-related
|
||||||
// setup.
|
// setup. Subclasses should return false if setup fails.
|
||||||
virtual void OnCreate();
|
virtual bool OnCreate();
|
||||||
|
|
||||||
// Called when Destroy is called.
|
// Called when Destroy is called.
|
||||||
virtual void OnDestroy();
|
virtual void OnDestroy();
|
||||||
|
Loading…
Reference in New Issue
Block a user