mirror of https://github.com/bkaradzic/bgfx
fix deadlock and remove unused bx::Error (#2589)
This commit is contained in:
parent
be0e7ef307
commit
8f60971dd6
|
@ -58,16 +58,15 @@ bool openFileSelectionDialog(
|
|||
)
|
||||
{
|
||||
NSMutableArray* fileTypes = [NSMutableArray arrayWithCapacity:10];
|
||||
bx::Error err;
|
||||
|
||||
for (bx::LineReader lr(_filter); !lr.isDone() && err.isOk();)
|
||||
for (bx::LineReader lr(_filter); !lr.isDone();)
|
||||
{
|
||||
const bx::StringView line = lr.next();
|
||||
const bx::StringView sep = bx::strFind(line, '|');
|
||||
|
||||
if (!sep.isEmpty() )
|
||||
{
|
||||
for (Split split(bx::strTrim(bx::StringView(sep.getPtr()+1, line.getTerm() ), " "), ' '); !split.isDone() && err.isOk();)
|
||||
for (Split split(bx::strTrim(bx::StringView(sep.getPtr()+1, line.getTerm() ), " "), ' '); !split.isDone();)
|
||||
{
|
||||
const bx::StringView token = split.next();
|
||||
|
||||
|
@ -82,14 +81,8 @@ bool openFileSelectionDialog(
|
|||
}
|
||||
|
||||
__block NSString* fileName = nil;
|
||||
bx::Semaphore semaphore;
|
||||
bx::Semaphore* psemaphore = &semaphore;
|
||||
|
||||
CFRunLoopPerformBlock([[NSRunLoop mainRunLoop] getCFRunLoop],
|
||||
kCFRunLoopCommonModes,
|
||||
^{
|
||||
void (^invokeDialog)(void) = ^{
|
||||
NSSavePanel* panel = nil;
|
||||
|
||||
if ( FileSelectionDialogType::Open == _type)
|
||||
{
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
|
@ -117,10 +110,25 @@ bool openFileSelectionDialog(
|
|||
}
|
||||
}
|
||||
[panel close];
|
||||
};
|
||||
|
||||
if ([NSThread isMainThread])
|
||||
{
|
||||
invokeDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
bx::Semaphore semaphore;
|
||||
bx::Semaphore* psemaphore = &semaphore;
|
||||
|
||||
CFRunLoopPerformBlock([[NSRunLoop mainRunLoop] getCFRunLoop],
|
||||
kCFRunLoopCommonModes,
|
||||
^{
|
||||
invokeDialog();
|
||||
psemaphore->post();
|
||||
});
|
||||
|
||||
semaphore.wait();
|
||||
}
|
||||
|
||||
if ( fileName != nil )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue