summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2019-02-12 12:39:31 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2021-10-15 09:29:32 +0800
commit4d1cb6c3cccdcab1ec081f2c74b0fca54efec490 (patch)
treea229a91b0c8fd7fb482589997f60b4b1bf3a2498
parenta8940a1f4f700c8d84589fa87655a8fd6b268a56 (diff)
downloadcogl-4d1cb6c3cccdcab1ec081f2c74b0fca54efec490.tar.gz
cogl-crate.c: Fix running on 64-bit Windows
CoglPollFD uses an int type for its fd member but the GPollFD that g_poll() expects uses a gint64 type (a.k.a int64_t, __in64 on Windows) for its fd member on 64-bit Windows, which will cause loads of "WaitForMultipleObjectsEx failed:..." to be spewed from GLib on 64-bit Windows. This updates the example to use the correct types for the g_poll() call, which will avoid this kind of situation.
-rw-r--r--examples/cogl-crate.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index d04e3085..7b5256f0 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -276,6 +276,7 @@ main (int argc, char **argv)
while (1)
{
CoglPollFD *poll_fds;
+ GPollFD gpoll_fds;
int n_poll_fds;
int64_t timeout;
@@ -288,9 +289,18 @@ main (int argc, char **argv)
cogl_poll_renderer_get_info (cogl_context_get_renderer (ctx),
&poll_fds, &n_poll_fds, &timeout);
- g_poll ((GPollFD *) poll_fds, n_poll_fds,
+#if !defined G_OS_WIN32 || (GLIB_SIZEOF_VOID_P == 4)
+ gpoll_fds.fd = (int) poll_fds->fd;
+#else
+ gpoll_fds.fd = (int64_t) poll_fds->fd;
+#endif
+ gpoll_fds.events = poll_fds->events;
+ gpoll_fds.revents = poll_fds->revents;
+
+ g_poll (&gpoll_fds, n_poll_fds,
timeout == -1 ? -1 : timeout / 1000);
+
cogl_poll_renderer_dispatch (cogl_context_get_renderer (ctx),
poll_fds, n_poll_fds);
}