summaryrefslogtreecommitdiffstats
path: root/base/message_pump_glib.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 00:47:28 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 00:47:28 +0000
commita2f08b0c7b3dc722112d1871471dddfc23b28195 (patch)
tree12a7ebea564c955ce58f75cbeee0ca6e4d084170 /base/message_pump_glib.cc
parent18290eb6249c95069b20c3bdfc8163900d2a17a8 (diff)
downloadchromium_src-a2f08b0c7b3dc722112d1871471dddfc23b28195.zip
chromium_src-a2f08b0c7b3dc722112d1871471dddfc23b28195.tar.gz
chromium_src-a2f08b0c7b3dc722112d1871471dddfc23b28195.tar.bz2
Changes message_pump_glib not to crash if run without corresponding
run, or rather if run completes and another message comes through. This can happen during tests and the windows side explicitly allows this case to work. BUG=none TEST=none Review URL: http://codereview.chromium.org/558048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37586 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_glib.cc')
-rw-r--r--base/message_pump_glib.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc
index 3998390..630c2f9 100644
--- a/base/message_pump_glib.cc
+++ b/base/message_pump_glib.cc
@@ -220,7 +220,8 @@ void MessagePumpForUI::RunWithDispatcher(Delegate* delegate,
int MessagePumpForUI::HandlePrepare() {
// We know we have work, but we haven't called HandleDispatch yet. Don't let
// the pump block so that we can do some processing.
- if (state_->has_work)
+ if (state_ && // state_ may be null during tests.
+ state_->has_work)
return 0;
// We don't think we have work to do, but make sure not to block
@@ -229,6 +230,9 @@ int MessagePumpForUI::HandlePrepare() {
}
bool MessagePumpForUI::HandleCheck() {
+ if (!state_) // state_ may be null during tests.
+ return false;
+
// We should only ever have a single message on the wakeup pipe, since we
// are only signaled when the queue went from empty to non-empty. The glib
// poll will tell us whether there was data, so this read shouldn't block.
@@ -317,7 +321,8 @@ void MessagePumpForUI::EventDispatcher(GdkEvent* event, gpointer data) {
MessagePumpForUI* message_pump = reinterpret_cast<MessagePumpForUI*>(data);
message_pump->WillProcessEvent(event);
- if (message_pump->state_->dispatcher) {
+ if (message_pump->state_ && // state_ may be null during tests.
+ message_pump->state_->dispatcher) {
if (!message_pump->state_->dispatcher->Dispatch(event))
message_pump->state_->should_quit = true;
} else {