macOS: Rename the window only on the main thread: macOS doesn't like non-main threads modifying the UI.
This commit is contained in:
parent
33da24d0e2
commit
20d7014e4a
1 changed files with 18 additions and 1 deletions
19
src/pc.c
19
src/pc.c
|
|
@ -1,9 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#if defined(__APPLE__) && defined(__aarch64__)
|
||||
#ifdef __APPLE__
|
||||
#include <string.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
#ifdef __aarch64__
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "ibm.h"
|
||||
#include "device.h"
|
||||
|
||||
|
|
@ -519,6 +523,14 @@ int serial_fifo_read, serial_fifo_write;
|
|||
|
||||
int emu_fps = 0;
|
||||
|
||||
#ifdef __APPLE__
|
||||
static void _set_window_title(void *s)
|
||||
{
|
||||
set_window_title((const char *)s);
|
||||
free(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
void runpc()
|
||||
{
|
||||
char s[200];
|
||||
|
|
@ -594,7 +606,12 @@ void runpc()
|
|||
{
|
||||
win_title_update=0;
|
||||
sprintf(s, "PCem v17 - %i%% - %s - %s - %s", fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? "Press CTRL-END to release mouse" : "Press CTRL-END or middle button to release mouse"));
|
||||
#ifdef __APPLE__
|
||||
// Needed due to modifying the UI on the non-main thread is a big no-no.
|
||||
dispatch_async_f(dispatch_get_main_queue(), strdup(s), _set_window_title);
|
||||
#else
|
||||
set_window_title(s);
|
||||
#endif
|
||||
}
|
||||
done++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue