summaryrefslogtreecommitdiff
path: root/src/load-graph.cpp
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-02-03 20:21:33 +0100
committerraveit65 <[email protected]>2020-02-17 13:17:24 +0100
commita50443572b52ace61f442a121d0ecc386c853173 (patch)
tree617242d3b55a76b09fc2a94a9afb7faa10b59ed4 /src/load-graph.cpp
parent3a223d2f65da06859a6fd1d9e80fa923cfe66d40 (diff)
downloadmate-system-monitor-a50443572b52ace61f442a121d0ecc386c853173.tar.bz2
mate-system-monitor-a50443572b52ace61f442a121d0ecc386c853173.tar.xz
Remove GTimeVal deprecation warning for GLib 2.61.2+
Diffstat (limited to 'src/load-graph.cpp')
-rw-r--r--src/load-graph.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index 107cf92..f4ba83f 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -529,7 +529,11 @@ get_net (LoadGraph *graph)
char **ifnames;
guint32 i;
guint64 in = 0, out = 0;
+#if GLIB_CHECK_VERSION(2,61,2)
+ gint64 time;
+#else
GTimeVal time;
+#endif
guint64 din, dout;
ifnames = glibtop_get_netlist(&netlist);
@@ -563,13 +567,20 @@ get_net (LoadGraph *graph)
g_strfreev(ifnames);
- g_get_current_time (&time);
+#if GLIB_CHECK_VERSION(2,61,2)
+ time = g_get_real_time ();
if (in >= graph->net.last_in && out >= graph->net.last_out &&
+ graph->net.time != 0) {
+ float dtime = (double) (time - graph->net.time) / G_USEC_PER_SEC;
+#else
+ g_get_current_time (&time);
+ if (in >= graph->net.last_in && out >= graph->net.last_out &&
graph->net.time.tv_sec != 0) {
float dtime;
dtime = time.tv_sec - graph->net.time.tv_sec +
(double) (time.tv_usec - graph->net.time.tv_usec) / G_USEC_PER_SEC;
+#endif
din = static_cast<guint64>((in - graph->net.last_in) / dtime);
dout = static_cast<guint64>((out - graph->net.last_out) / dtime);
} else {