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

Unified Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc

Issue 2398723002: Fix crash in aura::Window::GetHost (Closed)
Patch Set: Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
diff --git a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
index d37f9be03c1e32e364f41512be8e72cbd2f3e610..5ccff627f91b2272c323b613989a4caa8160a828 100644
--- a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
+++ b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc
@@ -170,16 +170,18 @@ void SelectFileDialogImplGTK::SelectFileImpl(
params_map_[dialog] = params;
// Disable input events handling in the host window to make this dialog modal.
- views::DesktopWindowTreeHostX11* host =
- views::DesktopWindowTreeHostX11::GetHostForXID(
- owning_window->GetHost()->GetAcceleratedWidget());
- std::unique_ptr<base::Closure> callback = host->DisableEventListening(
- GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
- // OnFilePickerDestroy() is called when |dialog| destroyed, which allows to
- // invoke the callback function to re-enable events on the owning window.
- g_object_set_data_full(G_OBJECT(dialog), "callback", callback.release(),
- reinterpret_cast<GDestroyNotify>(OnFilePickerDestroy));
- gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+ aura::WindowTreeHost* host = owning_window->GetHost();
+ if (host) {
+ std::unique_ptr<base::Closure> callback =
+ views::DesktopWindowTreeHostX11::GetHostForXID(
+ host->GetAcceleratedWidget())->DisableEventListening(
+ GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
+ // OnFilePickerDestroy() is called when |dialog| destroyed, which allows to
+ // invoke the callback function to re-enable events on the owning window.
+ g_object_set_data_full(G_OBJECT(dialog), "callback", callback.release(),
+ reinterpret_cast<GDestroyNotify>(OnFilePickerDestroy));
+ gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+ }
gtk_widget_show_all(dialog);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698