Handle deprecation of GTimeVal (#575)

`GTimeVal` has been deprecated in glib 2.62 . While switching to `g_get_monotonic_time()`, I realized that we could simply reuse `fluid_utime()` for that purpose.
This commit is contained in:
Tom M 2019-10-22 17:39:08 +02:00 committed by GitHub
parent dfcf5c019f
commit 64cee5537d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -313,22 +313,21 @@ void fluid_msleep(unsigned int msecs)
/**
* Get time in milliseconds to be used in relative timing operations.
* @return Unix time in milliseconds.
* @return Monotonic time in milliseconds.
*/
unsigned int fluid_curtime(void)
{
static glong initial_seconds = 0;
GTimeVal timeval;
float now;
static float initial_time = 0;
if(initial_seconds == 0)
if(initial_time == 0)
{
g_get_current_time(&timeval);
initial_seconds = timeval.tv_sec;
initial_time = (float)fluid_utime();
}
g_get_current_time(&timeval);
now = (float)fluid_utime();
return (unsigned int)((timeval.tv_sec - initial_seconds) * 1000.0 + timeval.tv_usec / 1000.0);
return (unsigned int)((now - initial_time) / 1000.0f);
}
/**