vnc: fix crashes when disabling --calc

This commit is contained in:
Lephenixnoir 2023-03-27 16:43:47 +02:00
parent a3864fad21
commit e7ffe36061
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 9 additions and 5 deletions

View File

@ -44,8 +44,10 @@ static struct app app = { 0 };
static void cleanup(void)
{
/* Wait for libusb to settle down */
while(fxlink_device_list_interrupt(&app.devices))
libusb_handle_events(app.libusb_ctx);
if(app.libusb_ctx) {
while(fxlink_device_list_interrupt(&app.devices))
libusb_handle_events(app.libusb_ctx);
}
for(int i = 0; i < MONITOR_COUNT; i++) {
struct monitor *mon = app.monitors[i];
@ -420,9 +422,11 @@ int main(int argc, char **argv)
}
/* Run libusb's event loop */
struct timeval zero_tv = { 0 };
libusb_handle_events_timeout(app.libusb_ctx, &zero_tv);
fxlink_device_list_refresh(&app.devices);
if(app.libusb_ctx) {
struct timeval zero_tv = { 0 };
libusb_handle_events_timeout(app.libusb_ctx, &zero_tv);
fxlink_device_list_refresh(&app.devices);
}
/* Update monitors so they can attach to calculators */
for(int i = 0; i < MONITOR_COUNT; i++) {