Skip to content

Commit 8f2cbb3

Browse files
franciscojma86NoamDev
authored andcommitted
Code cleanup on destructors (flutter#16481)
1 parent e2bd8e4 commit 8f2cbb3

7 files changed

+10
-31
lines changed

shell/platform/windows/testing/win32_flutter_window_test.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
2-
#include <iostream>
32

43
namespace flutter {
54
namespace testing {

shell/platform/windows/testing/win32_flutter_window_test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Win32FlutterWindowTest : public Win32FlutterWindow {
1414
public:
1515
Win32FlutterWindowTest(int width, int height);
1616

17-
~Win32FlutterWindowTest();
17+
virtual ~Win32FlutterWindowTest();
1818

1919
// |Win32Window|
2020
void OnFontChange() override;

shell/platform/windows/win32_flutter_window.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace flutter {
66

7-
// the Windows DPI system is based on this
7+
// The Windows DPI system is based on this
88
// constant for machines running at 100% scaling.
99
constexpr int base_dpi = 96;
1010

@@ -15,7 +15,6 @@ Win32FlutterWindow::Win32FlutterWindow(int width, int height) {
1515

1616
Win32FlutterWindow::~Win32FlutterWindow() {
1717
DestroyRenderSurface();
18-
Win32Window::Destroy();
1918
}
2019

2120
FlutterDesktopViewControllerRef Win32FlutterWindow::CreateWin32FlutterWindow(
@@ -177,10 +176,6 @@ void Win32FlutterWindow::OnScroll(double delta_x, double delta_y) {
177176
}
178177
}
179178

180-
void Win32FlutterWindow::OnClose() {
181-
messageloop_running_ = false;
182-
}
183-
184179
void Win32FlutterWindow::OnFontChange() {
185180
if (engine_ == nullptr) {
186181
return;
@@ -358,5 +353,4 @@ void Win32FlutterWindow::DestroyRenderSurface() {
358353
}
359354
render_surface = EGL_NO_SURFACE;
360355
}
361-
362356
} // namespace flutter

shell/platform/windows/win32_flutter_window.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Win32FlutterWindow : public Win32Window {
3333
// Create flutter Window for use as child window
3434
Win32FlutterWindow(int width, int height);
3535

36-
~Win32FlutterWindow();
36+
virtual ~Win32FlutterWindow();
3737

3838
static FlutterDesktopViewControllerRef CreateWin32FlutterWindow(int width,
3939
int height);
@@ -65,9 +65,6 @@ class Win32FlutterWindow : public Win32Window {
6565
// |Win32Window|
6666
void OnScroll(double delta_x, double delta_y) override;
6767

68-
// |Win32Window|
69-
void OnClose() override;
70-
7168
// |Win32Window|
7269
void OnFontChange() override;
7370

@@ -85,9 +82,6 @@ class Win32FlutterWindow : public Win32Window {
8582
// Create a surface for Flutter engine to render into.
8683
void CreateRenderSurface();
8784

88-
// Destroy current rendering surface if one has been allocated.
89-
void DestroyRenderSurface();
90-
9185
// Callbacks for clearing context, settings context and swapping buffers.
9286
bool ClearContext();
9387
bool MakeCurrent();
@@ -99,6 +93,9 @@ class Win32FlutterWindow : public Win32Window {
9993
void SendWindowMetrics();
10094

10195
private:
96+
// Destroy current rendering surface if one has been allocated.
97+
void DestroyRenderSurface();
98+
10299
// Reports a mouse movement to Flutter engine.
103100
void SendPointerMove(double x, double y);
104101

@@ -174,9 +171,6 @@ class Win32FlutterWindow : public Win32Window {
174171

175172
// should we forword input messages or not
176173
bool process_events_ = false;
177-
178-
// flag indicating if the message loop should be running
179-
bool messageloop_running_ = false;
180174
};
181175

182176
} // namespace flutter

shell/platform/windows/win32_window.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ Win32Window::MessageHandler(HWND hwnd,
112112
case kWmDpiChangedBeforeParent:
113113
return HandleDpiChange(window_handle_, wparam, lparam, false);
114114
break;
115-
case WM_DESTROY:
116-
window->OnClose();
117-
return 0;
118-
break;
119115
case WM_SIZE:
120116
width = LOWORD(lparam);
121117
height = HIWORD(lparam);

shell/platform/windows/win32_window.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct MouseState {
3737
class Win32Window {
3838
public:
3939
Win32Window();
40-
~Win32Window();
40+
virtual ~Win32Window();
4141

4242
// Initializes as a child window with size using |width| and |height| and
4343
// |title| to identify the windowclass. Does not show window, window must be
@@ -46,9 +46,6 @@ class Win32Window {
4646
unsigned int width,
4747
unsigned int height);
4848

49-
// Release OS resources asociated with window.
50-
virtual void Destroy();
51-
5249
HWND GetWindowHandle();
5350

5451
protected:
@@ -116,9 +113,6 @@ class Win32Window {
116113
// Called when mouse scrollwheel input occurs.
117114
virtual void OnScroll(double delta_x, double delta_y) = 0;
118115

119-
// Called when the user closes the Windows.
120-
virtual void OnClose() = 0;
121-
122116
// Called when the system font change.
123117
virtual void OnFontChange() = 0;
124118

@@ -150,6 +144,9 @@ class Win32Window {
150144
void SetMouseButtons(uint64_t buttons) { mouse_state_.buttons = buttons; }
151145

152146
private:
147+
// Release OS resources asociated with window.
148+
void Destroy();
149+
153150
// Activates tracking for a "mouse leave" event.
154151
void TrackMouseLeaveEvent(HWND hwnd);
155152

shell/platform/windows/win32_window_unittests.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ TEST(Win32FlutterWindowTest, CanFontChange) {
1515
LRESULT result = SendMessage(hwnd, WM_FONTCHANGE, NULL, NULL);
1616
ASSERT_EQ(result, 0);
1717
ASSERT_TRUE(window.OnFontChangeWasCalled());
18-
ASSERT_TRUE(TRUE);
1918
}
2019

2120
} // namespace testing

0 commit comments

Comments
 (0)