summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryukishiino <yukishiino@chromium.org>2014-09-27 04:56:38 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-27 11:57:10 +0000
commit1291d0c2e4435561edcc260aa0b3337dbd583eda (patch)
tree53efb2f83a5131f338f9a9e6eb9947e649babb8c
parentbd3ad7a6a3a94a532a3ee3e73f3c92c2f1b746e5 (diff)
downloadchromium_src-1291d0c2e4435561edcc260aa0b3337dbd583eda.zip
chromium_src-1291d0c2e4435561edcc260aa0b3337dbd583eda.tar.gz
chromium_src-1291d0c2e4435561edcc260aa0b3337dbd583eda.tar.bz2
linux: Fixes a racy crash by key input at termination.
It seems that it's possible that GDK events happen while we're going to unregister the GDK event handler, and the code must be thread-safe. (A gpointer |data| in the old code seems pointing to the deleted object.) This CL removes use of |data| pointer and makes the code thread-safe without adding any mutex. BUG=417210 Review URL: https://codereview.chromium.org/610523002 Cr-Commit-Position: refs/heads/master@{#297112}
-rw-r--r--chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc10
-rw-r--r--chrome/browser/ui/libgtk2ui/gtk2_event_loop.h6
2 files changed, 5 insertions, 11 deletions
diff --git a/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc b/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc
index 9f71177..e48c186 100644
--- a/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc
+++ b/chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc
@@ -20,7 +20,7 @@ Gtk2EventLoop* Gtk2EventLoop::GetInstance() {
}
Gtk2EventLoop::Gtk2EventLoop() {
- gdk_event_handler_set(GdkEventTrampoline, this, NULL);
+ gdk_event_handler_set(DispatchGdkEvent, NULL, NULL);
}
Gtk2EventLoop::~Gtk2EventLoop() {
@@ -29,12 +29,7 @@ Gtk2EventLoop::~Gtk2EventLoop() {
}
// static
-void Gtk2EventLoop::GdkEventTrampoline(GdkEvent* event, gpointer data) {
- Gtk2EventLoop* loop = reinterpret_cast<Gtk2EventLoop*>(data);
- loop->DispatchGdkEvent(event);
-}
-
-void Gtk2EventLoop::DispatchGdkEvent(GdkEvent* gdk_event) {
+void Gtk2EventLoop::DispatchGdkEvent(GdkEvent* gdk_event, gpointer) {
switch (gdk_event->type) {
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
@@ -47,6 +42,7 @@ void Gtk2EventLoop::DispatchGdkEvent(GdkEvent* gdk_event) {
gtk_main_do_event(gdk_event);
}
+// static
void Gtk2EventLoop::ProcessGdkEventKey(const GdkEventKey& gdk_event_key) {
// This function translates GdkEventKeys into XKeyEvents and puts them to
// the X event queue.
diff --git a/chrome/browser/ui/libgtk2ui/gtk2_event_loop.h b/chrome/browser/ui/libgtk2ui/gtk2_event_loop.h
index d52e4fd..0bd2a21 100644
--- a/chrome/browser/ui/libgtk2ui/gtk2_event_loop.h
+++ b/chrome/browser/ui/libgtk2ui/gtk2_event_loop.h
@@ -25,10 +25,8 @@ class Gtk2EventLoop {
Gtk2EventLoop();
~Gtk2EventLoop();
- static void GdkEventTrampoline(GdkEvent* event, gpointer data);
-
- void DispatchGdkEvent(GdkEvent* gdk_event);
- void ProcessGdkEventKey(const GdkEventKey& gdk_event_key);
+ static void DispatchGdkEvent(GdkEvent* gdk_event, gpointer);
+ static void ProcessGdkEventKey(const GdkEventKey& gdk_event_key);
DISALLOW_COPY_AND_ASSIGN(Gtk2EventLoop);
};