summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/message_pump_glib.cc11
-rw-r--r--base/message_pump_glib.h3
2 files changed, 9 insertions, 5 deletions
diff --git a/base/message_pump_glib.cc b/base/message_pump_glib.cc
index 603c80ea..f837f597 100644
--- a/base/message_pump_glib.cc
+++ b/base/message_pump_glib.cc
@@ -54,7 +54,8 @@ static int GetTimeIntervalMilliseconds(Time from) {
MessagePumpForUI::MessagePumpForUI()
: state_(NULL),
- context_(g_main_context_default()) {
+ context_(g_main_context_default()),
+ work_source_poll_fd_(new GPollFD) {
// Create a pipe with a non-blocking read end for use by ScheduleWork to
// break us out of a poll. Create the work source and attach the file
// descriptor to it.
@@ -67,10 +68,10 @@ MessagePumpForUI::MessagePumpForUI()
flags = 0;
CHECK(0 == fcntl(read_fd_work_scheduled_, F_SETFL, flags | O_NONBLOCK)) <<
"Could not set file descriptor to non-blocking!";
- GPollFD poll_fd;
- poll_fd.fd = read_fd_work_scheduled_;
- poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
- work_source_ = AddSource(&WorkSourceFuncs, G_PRIORITY_DEFAULT, &poll_fd);
+ work_source_poll_fd_->fd = read_fd_work_scheduled_;
+ work_source_poll_fd_->events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+ work_source_ = AddSource(&WorkSourceFuncs, G_PRIORITY_DEFAULT,
+ work_source_poll_fd_.get());
}
MessagePumpForUI::~MessagePumpForUI() {
diff --git a/base/message_pump_glib.h b/base/message_pump_glib.h
index 97daa8a..01cd4b6 100644
--- a/base/message_pump_glib.h
+++ b/base/message_pump_glib.h
@@ -8,6 +8,7 @@
#include <glib.h>
#include "base/message_pump.h"
+#include "base/scoped_ptr.h"
#include "base/time.h"
namespace base {
@@ -91,6 +92,8 @@ class MessagePumpForUI : public MessagePump {
// The work source. It is shared by all calls to Run and destroyed when
// the message pump is destroyed.
GSource* work_source_;
+ // The GLib poll structure needs to be owned and freed by us.
+ scoped_ptr<GPollFD> work_source_poll_fd_;
DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI);
};