From 98dc75e02fe580dde18c5fd37efde3d655359d38 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Tue, 8 Nov 2022 14:53:51 -0800 Subject: [PATCH] Fix bad performance with TimerFileWatcher --- TimerApplication.c | 2 +- TimerClock.c | 2 +- TimerFileWatcher.c | 1 + TimerTaskTree.c | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TimerApplication.c b/TimerApplication.c index 68e29dd..696bbea 100644 --- a/TimerApplication.c +++ b/TimerApplication.c @@ -57,7 +57,7 @@ static void timer_application_activate(GApplication *app) { } TimerApplication *timer_application_new() { - return g_object_new(TIMER_TYPE_APPLICATION, "application-id", "org.zander.practicetiemr", "flags", G_APPLICATION_FLAGS_NONE, NULL); + return g_object_new(TIMER_TYPE_APPLICATION, "application-id", "org.zander.practicetiemr", "flags", G_APPLICATION_DEFAULT_FLAGS, NULL); } const char *timer_application_get_config_file(TimerApplication *self) { diff --git a/TimerClock.c b/TimerClock.c index 219143e..676ace4 100644 --- a/TimerClock.c +++ b/TimerClock.c @@ -25,7 +25,7 @@ static void timer_clock_thread_callback(TimerClock *self) { self->lastTick = now; self->currentTime = 0; } - g_usleep(50); + g_usleep(500); } } diff --git a/TimerFileWatcher.c b/TimerFileWatcher.c index 0ff7e7c..9e5e4b7 100644 --- a/TimerFileWatcher.c +++ b/TimerFileWatcher.c @@ -31,6 +31,7 @@ static void timer_file_watcher_tick(TimerFileWatcher *self) { } last_tick = now; } + g_usleep(500); } } diff --git a/TimerTaskTree.c b/TimerTaskTree.c index 8e22717..dbec9c3 100644 --- a/TimerTaskTree.c +++ b/TimerTaskTree.c @@ -396,6 +396,7 @@ void timer_task_tree_set_data_path(TimerTaskTree *self, const char *path) { if (self->fileWatcher) { g_object_unref(self->fileWatcher); } + self->fileWatcher = NULL; self->fileWatcher = timer_file_watcher_new(path); g_signal_connect(self->fileWatcher, "file-changed", G_CALLBACK(data_file_updated), self); }