[glibmm] Glib::Dispatcher: Don't cast a HANDLE to an int on Windows
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Glib::Dispatcher: Don't cast a HANDLE to an int on Windows
- Date: Tue, 6 Dec 2016 15:45:14 +0000 (UTC)
commit da9c5f725335b7b819a3909faff5bd53bdec4299
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Tue Dec 6 16:41:14 2016 +0100
Glib::Dispatcher: Don't cast a HANDLE to an int on Windows
* glib/glibmm/dispatcher.cc: When a Windows HANDLE must be cast, cast it
to Glib::PollFD::fd_t instead of int. Bug 772074
glib/glibmm/dispatcher.cc | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index 3c8a65d..73b69be 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -165,8 +165,6 @@ private:
/**** Glib::DispatchNotifier ***********************************************/
-// static
-
thread_local DispatchNotifier* DispatchNotifier::thread_specific_instance_ = nullptr;
DispatchNotifier::DispatchNotifier(const Glib::RefPtr<MainContext>& context)
@@ -186,11 +184,11 @@ DispatchNotifier::DispatchNotifier(const Glib::RefPtr<MainContext>& context)
try
{
-#ifdef G_OS_WIN32
- const int fd = GPOINTER_TO_INT(fd_receiver_);
-#else
- const int fd = fd_receiver_;
-#endif
+ // PollFD::fd_t is the type of GPollFD::fd.
+ // In Windows, it has the same size as HANDLE, but it's not guaranteed to be the same type.
+ // In Unix, a file descriptor is an int.
+ const auto fd = (PollFD::fd_t)fd_receiver_;
+
// The following code is equivalent to
// context_->signal_io().connect(
// sigc::mem_fun(*this, &DispatchNotifier::pipe_io_handler), fd, Glib::IO_IN);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]