Bug 527214 – g_timer_elapsed() returns random values.

* glib/gtimer.c (g_timer_new()):
        Print warning if g_thread_init() has not been called yet.
        Patch by Mathias Hasselmann


svn path=/trunk/; revision=6907
This commit is contained in:
Matthias Clasen 2008-05-18 19:15:32 +00:00
parent 4f21fe18cb
commit 4b06cf6ce9
4 changed files with 27 additions and 0 deletions

View File

@ -1,3 +1,11 @@
2008-05-18 Matthias Clasen <mclasen@redhat.com>
Bug 527214 g_timer_elapsed() returns random values.
* glib/gtimer.c (g_timer_new()):
Print warning if g_thread_init() has not been called yet.
Patch by Mathias Hasselmann
2008-05-12 Jeffrey Stedfast <fejj@novell.com> 2008-05-12 Jeffrey Stedfast <fejj@novell.com>
* glib/gchecksum.c (g_checksum_reset): New function to reset the * glib/gchecksum.c (g_checksum_reset): New function to reset the

View File

@ -1,3 +1,11 @@
2008-05-18 Matthias Clasen <mclasen@redhat.com>
Bug 527214 g_timer_elapsed() returns random values.
* docs/reference/glib/tmpl/timers.sgml:
Add notes regarding gthreads dependency.
Patch by Mathias Hasselmann
2008-05-17 Matthias Clasen <mclasen@redhat.com> 2008-05-17 Matthias Clasen <mclasen@redhat.com>
* gio/gio-sections.txt: Add new api * gio/gio-sections.txt: Add new api

View File

@ -10,6 +10,10 @@ keep track of elapsed time
This is done somewhat differently on different platforms, and can be tricky to This is done somewhat differently on different platforms, and can be tricky to
get exactly right, so #GTimer provides a portable/convenient interface. get exactly right, so #GTimer provides a portable/convenient interface.
</para> </para>
<note><para>
#GTimer internally uses the threading API. Therefore g_thread_init() has to be
called before creating #GTimer instances.
</para></note>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
@ -30,6 +34,9 @@ Opaque datatype that records a start time.
Creates a new timer, and starts timing (i.e. g_timer_start() is implicitly Creates a new timer, and starts timing (i.e. g_timer_start() is implicitly
called for you). called for you).
</para> </para>
<note><para>
Call g_thread_init() before using this function.
</para></note>
@Returns: a new #GTimer. @Returns: a new #GTimer.

View File

@ -69,6 +69,10 @@ g_timer_new (void)
{ {
GTimer *timer; GTimer *timer;
if (!g_thread_supported ())
g_warning ("g_timer_new() called, but GThreads not initialized yet. "
"Call g_thread_init ().");
timer = g_new (GTimer, 1); timer = g_new (GTimer, 1);
timer->active = TRUE; timer->active = TRUE;