Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: views/controls/native_control_gtk.cc

Issue 510004: Fix crash/leak issue in native_view_host_gtk.cc. (Closed)
Patch Set: " Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « views/controls/native/native_view_host_wrapper.h ('k') | views/widget/widget_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "views/controls/native_control_gtk.h" 5 #include "views/controls/native_control_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "views/focus/focus_manager.h" 10 #include "views/focus/focus_manager.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // controls need a parent widget to function properly. 42 // controls need a parent widget to function properly.
43 CreateNativeControl(); 43 CreateNativeControl();
44 } 44 }
45 } 45 }
46 46
47 void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) { 47 void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) {
48 if (!is_visible) { 48 if (!is_visible) {
49 if (native_view()) { 49 if (native_view()) {
50 // We destroy the child widget when we become invisible because of the 50 // We destroy the child widget when we become invisible because of the
51 // performance cost of maintaining widgets that aren't currently needed. 51 // performance cost of maintaining widgets that aren't currently needed.
52 GtkWidget* widget = native_view();
53 Detach(); 52 Detach();
54 gtk_widget_destroy(widget); 53 // Make sure that Detach destroyed the widget.
54 DCHECK(!native_view());
55 } 55 }
56 } else if (!native_view()) { 56 } else if (!native_view()) {
57 if (GetWidget()) 57 if (GetWidget())
58 CreateNativeControl(); 58 CreateNativeControl();
59 } else { 59 } else {
60 // The view becomes visible after native control is created. 60 // The view becomes visible after native control is created.
61 // Layout now. 61 // Layout now.
62 Layout(); 62 Layout();
63 } 63 }
64 } 64 }
(...skipping 24 matching lines...) Expand all
89 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the 89 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the
90 // options page is only based on views. 90 // options page is only based on views.
91 // NOTREACHED(); 91 // NOTREACHED();
92 NOTIMPLEMENTED(); 92 NOTIMPLEMENTED();
93 return; 93 return;
94 } 94 }
95 focus_manager->SetFocusedView(control->focus_view()); 95 focus_manager->SetFocusedView(control->focus_view());
96 } 96 }
97 97
98 } // namespace views 98 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/native/native_view_host_wrapper.h ('k') | views/widget/widget_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698