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

Unified Diff: chrome/browser/ui/gtk/dialogs_gtk.cc

Issue 6873082: Fix DELETE_EVENT handling in 3 places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 8 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
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) {
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc » ('j') | chrome/browser/ui/gtk/js_modal_dialog_gtk.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698