[glibmm/glibmm-2-50] 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/glibmm-2-50] Glib::Dispatcher: Don't cast a HANDLE to an int on Windows
- Date: Mon, 12 Dec 2016 08:29:20 +0000 (UTC)
commit 0cf0e6aabc983f30491cabb8713700caf42bffef
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Mon Dec 12 09:25:56 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 | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index e21914a..d9067a3 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -198,11 +198,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]