[gtk+/gtk-2-24] quartz: add evil casting to make sure time wraps correctly on 32bit machines
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] quartz: add evil casting to make sure time wraps correctly on 32bit machines
- Date: Thu, 23 Aug 2012 07:32:56 +0000 (UTC)
commit c0c3085128b0af739c73db31f9330508aad8f2e6
Author: Michael Natterer <mitch gimp org>
Date: Thu Aug 23 09:28:13 2012 +0200
quartz: add evil casting to make sure time wraps correctly on 32bit machines
get_time_from_ns_event(): apply patch from Michael Hutchinson which
makes sure the returned guint32 wraps correctly on 32 bit machines
when the uptime exceeds 2^32 ms.
(cherry picked from commit 78506bd604099161819ffdd0fdef98967f8980de)
gdk/quartz/gdkevents-quartz.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c
index 9478c16..744de52 100644
--- a/gdk/quartz/gdkevents-quartz.c
+++ b/gdk/quartz/gdkevents-quartz.c
@@ -224,8 +224,11 @@ static guint32
get_time_from_ns_event (NSEvent *event)
{
double time = [event timestamp];
-
- return time * 1000.0;
+
+ /* cast via double->uint64 conversion to make sure that it is
+ * wrapped on 32-bit machines when it overflows
+ */
+ return (guint32) (guint64) (time * 1000.0);
}
static int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]