diff --git a/src/osx_app.m b/src/osx_app.m index ac8a5ca..d690217 100644 --- a/src/osx_app.m +++ b/src/osx_app.m @@ -1712,14 +1712,10 @@ void mg_osx_surface_set_frame(mg_surface_data* surface, mp_rect frame) {@autoreleasepool{ CGRect cgFrame = {{frame.x, frame.y}, {frame.w, frame.h}}; -// dispatch_async(dispatch_get_main_queue(), -// ^{ - [CATransaction begin]; - [CATransaction setDisableActions:YES]; - [surface->layer.caLayer setFrame: cgFrame]; - [CATransaction commit]; -// }); - + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + [surface->layer.caLayer setFrame: cgFrame]; + [CATransaction commit]; }} bool mg_osx_surface_get_hidden(mg_surface_data* surface) @@ -2222,27 +2218,44 @@ int mp_alert_popup(const char* title, uint32 count, const char** options) { - @autoreleasepool - { - NSWindow *keyWindow = [NSApp keyWindow]; + __block int result = 0; - NSAlert* alert = [[NSAlert alloc] init]; - NSString* string; - for(int i=count-1;i>=0;i--) + dispatch_block_t block = ^{ + @autoreleasepool { - string = [[NSString alloc] initWithUTF8String:options[i]]; - [alert addButtonWithTitle:string]; - [string release]; - } - string = [[NSString alloc] initWithUTF8String:message]; - [alert setMessageText:string]; - [string release]; + NSWindow *keyWindow = [NSApp keyWindow]; - [alert setAlertStyle:NSAlertStyleWarning]; - int result = count - ([alert runModal]-NSAlertFirstButtonReturn) - 1; - [keyWindow makeKeyWindow]; - return(result); + NSAlert* alert = [[NSAlert alloc] init]; + NSString* string; + for(int i=count-1;i>=0;i--) + { + string = [[NSString alloc] initWithUTF8String:options[i]]; + [alert addButtonWithTitle:string]; + [string release]; + } + string = [[NSString alloc] initWithUTF8String:title]; + [alert setMessageText:string]; + [string release]; + + string = [[NSString alloc] initWithUTF8String:message]; + [alert setInformativeText:string]; + [string release]; + + [alert setAlertStyle:NSAlertStyleWarning]; + result = count - ([alert runModal]-NSAlertFirstButtonReturn) - 1; + [keyWindow makeKeyWindow]; + } + }; + + if([NSThread isMainThread]) + { + block(); } + else + { + dispatch_sync(dispatch_get_main_queue(), block); + } + return(result); } diff --git a/src/platform/platform_varg.h b/src/platform/platform_varg.h new file mode 100644 index 0000000..5c2c713 --- /dev/null +++ b/src/platform/platform_varg.h @@ -0,0 +1,22 @@ +/************************************************************//** +* +* @file: platform_varg.h +* @author: Martin Fouilleul +* @date: 17/04/2023 +* +*****************************************************************/ +#ifndef __PLATFORM_VARG_H_ +#define __PLATFORM_VARG_H_ + +#include"platform.h" + +#if PLATFORM_ORCA + #define va_start __builtin_va_start + #define va_arg __builtin_va_arg + #define va_copy __builtin_va_copy + #define va_end __builtin_va_end +#else + #include +#endif + +#endif //__PLATFORM_VARG_H_ diff --git a/src/util/debug_log.c b/src/util/debug_log.c index c750b55..6dacb59 100644 --- a/src/util/debug_log.c +++ b/src/util/debug_log.c @@ -6,10 +6,11 @@ * @revision: * *****************************************************************/ -#include #include #include"debug_log.h" +#include"platform_varg.h" + static const char* LOG_HEADINGS[LOG_LEVEL_COUNT] = { "Error", "Warning", diff --git a/src/util/macro_helpers.h b/src/util/macro_helpers.h index dc3b93c..0c48f1a 100644 --- a/src/util/macro_helpers.h +++ b/src/util/macro_helpers.h @@ -124,10 +124,10 @@ static inline u64 next_pow2_u64(u64 x) #ifndef NO_ASSERT #ifdef PLATFORM_ORCA - //TODO add a runtime-provided assert - extern void orca_assert(bool x); + extern int orca_assert(const char* file, const char* function, int line, const char* src, const char* msg); - #define _ASSERT_(x, msg) orca_assert(x) + #define ORCA_ASSERT(x, msg) ((x) || orca_assert(__FILE__, __FUNCTION__, __LINE__, #x, msg)) + #define _ASSERT_(x, msg) ORCA_ASSERT(x, msg) #else #include #define _ASSERT_(x, msg) assert(x && msg)