Skip to content

Commit

Permalink
dialogs.c: move the scanning process into its own thread.
Browse files Browse the repository at this point in the history
On MacOS there were some issues with the network iio_context scanning
process. Inside libiio, some mutex locks are done during scanning. This
blocks the UI thread and makes the app unusable. Moving into its own thread
and creating a protected section (similar to calibration processes) should
resolve this issue.

Signed-off-by: AlexandraTrifan <[email protected]>
  • Loading branch information
AlexandraTrifan committed Apr 19, 2024
1 parent 0ce16d2 commit 971b129
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ static struct iio_context * get_context(Dialogs *data)
}
}

static void refresh_usb(void)

static void refresh_usb_thread(void)
{
struct iio_scan_context *ctxs;
struct iio_context_info **info;
Expand All @@ -447,6 +448,7 @@ static void refresh_usb(void)
bool scan = false;
gchar *active_uri = NULL;

gdk_threads_enter();
widget_set_cursor(dialogs.connect, GDK_WATCH);

if (gtk_combo_box_get_active(GTK_COMBO_BOX(dialogs.connect_usbd)) != -1) {
Expand Down Expand Up @@ -565,6 +567,7 @@ static void refresh_usb(void)
gtk_widget_set_sensitive(dialogs.connect_usbd, false);
/* Force a clear */
connect_clear(dialogs.connect_net);
gdk_threads_leave();
return;
}

Expand All @@ -585,6 +588,14 @@ static void refresh_usb(void)

/* Fill things in */
connect_clear(dialogs.connect_usb);
gdk_threads_leave();

}


static void refresh_usb(void)
{
g_thread_new("Scan thread", (void *) &refresh_usb_thread, NULL);
}

#ifdef SERIAL_BACKEND
Expand Down

0 comments on commit 971b129

Please sign in to comment.