| Index: chrome/browser/ui/gtk/dialogs_gtk.cc
|
| diff --git a/chrome/browser/ui/gtk/dialogs_gtk.cc b/chrome/browser/ui/gtk/dialogs_gtk.cc
|
| index e208d23e1a37e91319f475cc42c51b6829c16ebf..7487c09143ad27c2455a7daaffb62a267428df95 100644
|
| --- a/chrome/browser/ui/gtk/dialogs_gtk.cc
|
| +++ b/chrome/browser/ui/gtk/dialogs_gtk.cc
|
| @@ -83,9 +83,6 @@ class SelectFileDialogImpl : public SelectFileDialog {
|
| // |params_map_|.
|
| void* PopParamsForDialog(GtkWidget* dialog);
|
|
|
| - // Take care of internal data structures when a file dialog is destroyed.
|
| - void FileDialogDestroyed(GtkWidget* dialog);
|
| -
|
| // Check whether response_id corresponds to the user cancelling/closing the
|
| // dialog. Used as a helper for the below callbacks.
|
| bool IsCancelResponse(gint response_id);
|
| @@ -234,6 +231,7 @@ void SelectFileDialogImpl::SelectFileImpl(
|
| NOTREACHED();
|
| return;
|
| }
|
| + g_object_ref(dialog);
|
| dialogs_.insert(dialog);
|
|
|
| preview_ = gtk_image_new();
|
| @@ -321,6 +319,7 @@ void SelectFileDialogImpl::FileSelected(GtkWidget* dialog,
|
| g_slist_free(filters);
|
| listener_->FileSelected(path, idx + 1, PopParamsForDialog(dialog));
|
| }
|
| +
|
| gtk_widget_destroy(dialog);
|
| }
|
|
|
| @@ -337,7 +336,10 @@ void SelectFileDialogImpl::FileNotSelected(GtkWidget* dialog) {
|
| void* params = PopParamsForDialog(dialog);
|
| if (listener_)
|
| listener_->FileSelectionCanceled(params);
|
| - gtk_widget_destroy(dialog);
|
| + // In the GTK_RESPONSE_DELETE_EVENT case, the dialog will have already been
|
| + // destroyed.
|
| + if (dialogs_.find(dialog) != dialogs_.end())
|
| + gtk_widget_destroy(dialog);
|
| }
|
|
|
| bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread(const FilePath& path) {
|
| @@ -468,24 +470,6 @@ void* SelectFileDialogImpl::PopParamsForDialog(GtkWidget* dialog) {
|
| return params;
|
| }
|
|
|
| -void SelectFileDialogImpl::FileDialogDestroyed(GtkWidget* dialog) {
|
| - dialogs_.erase(dialog);
|
| -
|
| - // Parent may be NULL in a few cases: 1) on shutdown when
|
| - // AllBrowsersClosed() trigger this handler after all the browser
|
| - // windows got destroyed, or 2) when the parent tab has been opened by
|
| - // 'Open Link in New Tab' context menu on a downloadable item and
|
| - // the tab has no content (see the comment in SelectFile as well).
|
| - GtkWindow* parent = gtk_window_get_transient_for(GTK_WINDOW(dialog));
|
| - if (!parent)
|
| - return;
|
| - std::set<GtkWindow*>::iterator iter = parents_.find(parent);
|
| - if (iter != parents_.end())
|
| - parents_.erase(iter);
|
| - else
|
| - NOTREACHED();
|
| -}
|
| -
|
| bool SelectFileDialogImpl::IsCancelResponse(gint response_id) {
|
| bool is_cancel = response_id == GTK_RESPONSE_CANCEL ||
|
| response_id == GTK_RESPONSE_DELETE_EVENT;
|
| @@ -565,7 +549,21 @@ void SelectFileDialogImpl::OnSelectMultiFileDialogResponse(GtkWidget* dialog,
|
| }
|
|
|
| void SelectFileDialogImpl::OnFileChooserDestroy(GtkWidget* dialog) {
|
| - FileDialogDestroyed(dialog);
|
| + dialogs_.erase(dialog);
|
| +
|
| + // Parent may be NULL in a few cases: 1) on shutdown when
|
| + // AllBrowsersClosed() trigger this handler after all the browser
|
| + // windows got destroyed, or 2) when the parent tab has been opened by
|
| + // 'Open Link in New Tab' context menu on a downloadable item and
|
| + // the tab has no content (see the comment in SelectFile as well).
|
| + GtkWindow* parent = gtk_window_get_transient_for(GTK_WINDOW(dialog));
|
| + if (!parent)
|
| + return;
|
| + std::set<GtkWindow*>::iterator iter = parents_.find(parent);
|
| + if (iter != parents_.end())
|
| + parents_.erase(iter);
|
| + else
|
| + NOTREACHED();
|
| }
|
|
|
| void SelectFileDialogImpl::OnUpdatePreview(GtkWidget* chooser) {
|
|
|