Reimplement log_displayBox on macOS.
NSRunCriticalAlertPanel was replaced with the NSAlert class in 10.3 and deprecated in 10.10. This rewrite uses that class instead. Furthermore, original comments to the contrary, we are not compiling with ARC and need to actually release the classes we create and allow for an autorelease pool.
This commit is contained in:
@@ -21,17 +21,22 @@ void
|
||||
log_displayBox (const /*UTF-8*/char *title, int isError,
|
||||
const /*UTF-8*/char *msg)
|
||||
{
|
||||
NSString *titleStr = [NSString stringWithUTF8String:title];
|
||||
NSString *msgStr = [NSString stringWithUTF8String:msg];
|
||||
@autoreleasepool {
|
||||
NSAlert *alert = [[NSAlert alloc] init];
|
||||
NSString *titleStr = [NSString stringWithUTF8String:title];
|
||||
NSString *msgStr = [NSString stringWithUTF8String:msg];
|
||||
|
||||
if (!titleStr || !msgStr)
|
||||
return; // Oops, out of memory?
|
||||
if (alert && titleStr && msgStr) {
|
||||
alert.alertStyle = isError ? NSAlertStyleCritical : NSAlertStyleInformational;
|
||||
alert.messageText = titleStr;
|
||||
alert.informativeText = msgStr;
|
||||
|
||||
if (isError)
|
||||
NSRunCriticalAlertPanel (titleStr, @"%@", nil, nil, nil, msgStr);
|
||||
else
|
||||
NSRunInformationalAlertPanel (titleStr, @"%@", nil, nil, nil, msgStr);
|
||||
[alert runModal];
|
||||
}
|
||||
|
||||
// titleStr and msgStr are autoreleased
|
||||
[msgStr release];
|
||||
[titleStr release];
|
||||
[alert release];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user