diff options
Diffstat (limited to 'views/controls/native_control_gtk.cc')
-rw-r--r-- | views/controls/native_control_gtk.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/views/controls/native_control_gtk.cc b/views/controls/native_control_gtk.cc index 082e610..49453ef 100644 --- a/views/controls/native_control_gtk.cc +++ b/views/controls/native_control_gtk.cc @@ -35,21 +35,31 @@ void NativeControlGtk::ViewHierarchyChanged(bool is_add, View* parent, // Call the base class to hide the view if we're being removed. NativeViewHost::ViewHierarchyChanged(is_add, parent, child); - // Create the widget when we're added to a valid Widget. Many controls need a - // parent widget to function properly. - if (is_add && GetWidget() && !native_view()) + if (!is_add && child == this && native_view()) { + Detach(); + } else if (is_add && GetWidget() && !native_view()) { + // Create the widget when we're added to a valid Widget. Many + // controls need a parent widget to function properly. CreateNativeControl(); + } } void NativeControlGtk::VisibilityChanged(View* starting_from, bool is_visible) { if (!is_visible) { - // We destroy the child widget when we become invisible because of the - // performance cost of maintaining widgets that aren't currently needed. - GtkWidget* widget = native_view(); - Detach(); - gtk_widget_destroy(widget); + if (native_view()) { + // We destroy the child widget when we become invisible because of the + // performance cost of maintaining widgets that aren't currently needed. + GtkWidget* widget = native_view(); + Detach(); + gtk_widget_destroy(widget); + } } else if (!native_view()) { - CreateNativeControl(); + if (GetWidget()) + CreateNativeControl(); + } else { + // The view becomes visible after native control is created. + // Layout now. + Layout(); } } |