Chromium Code Reviews| Index: ash/wm/workspace/frame_maximize_button.cc |
| diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc |
| index 89297c5d76be29b2e73ba657faa2e1a32055fc1e..8ce51d47c1c4505f8ced3b4e463c3e2c35d032e2 100644 |
| --- a/ash/wm/workspace/frame_maximize_button.cc |
| +++ b/ash/wm/workspace/frame_maximize_button.cc |
| @@ -113,6 +113,7 @@ FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, |
| } |
| FrameMaximizeButton::~FrameMaximizeButton() { |
| + maximizer_.reset(); |
|
sky
2012/08/07 23:11:18
Add a comment as to why this needs to be first.
Mr4D (OOO till 08-26)
2012/08/08 01:02:28
Done.
|
| if (window_) |
| OnWindowDestroying(window_); |
| } |
| @@ -151,13 +152,24 @@ void FrameMaximizeButton::SnapButtonHovered(SnapType type) { |
| void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { |
| DCHECK_NE(snap_type_, SNAP_NONE); |
| - snap_type_ = snap_type; |
| - Snap(); |
| + // SNAP_MINIMIZE might destroy |this| for windows like the file manager. |
|
sky
2012/08/07 23:11:18
This is too fragile. Can't the code be like Proces
Mr4D (OOO till 08-26)
2012/08/08 01:02:28
Okay. Changed it. However - I did not move the cas
|
| + // To avoid crashes we have therefore to execute that command at the end. |
| + // All other commands need the snap_sizer to know the target size, so they |
| + // have to be executed before we start destroying the rest. |
| + if (snap_type != SNAP_MINIMIZE) { |
| + snap_type_ = snap_type; |
| + Snap(); |
| + } |
| // Remove any pending snap previews. |
| SnapButtonHovered(SNAP_NONE); |
| // At this point the operation has been performed and the menu should be |
| // closed - if not, it'll get now closed. |
| maximizer_.reset(); |
| + if (snap_type == SNAP_MINIMIZE) { |
| + snap_type_ = snap_type; |
| + Snap(); |
| + // |this| might now be destroyed. |
| + } |
| } |
| void FrameMaximizeButton::DestroyMaximizeMenu() { |