gattlib_glib_mainloop: Ensure mainloop is initialized before using it

latest-fixes
Olivier Martin 2024-04-03 21:47:14 +02:00
parent 2e99c4f1b6
commit b57d9546df
1 changed files with 2 additions and 2 deletions

View File

@ -33,8 +33,6 @@ int gattlib_mainloop(void* (*task)(void* arg), void *arg) {
};
GError* error;
GThread *task_thread = g_thread_try_new("gattlib_task", _execute_task, &execute_task_arg, &error);
if (m_main_loop != NULL) {
GATTLIB_LOG(GATTLIB_ERROR, "Main loop is already running: %s", error->message);
g_error_free(error);
@ -43,6 +41,8 @@ int gattlib_mainloop(void* (*task)(void* arg), void *arg) {
m_main_loop = g_main_loop_new(NULL, FALSE);
GThread *task_thread = g_thread_try_new("gattlib_task", _execute_task, &execute_task_arg, &error);
g_main_loop_run(m_main_loop);
g_main_loop_unref(m_main_loop);