Skip to content

Commit

Permalink
Open destination folders on macOS in separate thread
Browse files Browse the repository at this point in the history
In some unknown way, the one line in Objective-C affects Qt's main
loop causing the crash in QApplication::exec() on processing next
event after that call.

Even crash doesn't happen exactly after this call, it will happen
on application exit. Call stack and disassembly are the same in
all cases.

But running that code in another thread solves the issue.
  • Loading branch information
Kolcha committed Jul 2, 2022
1 parent 53ea184 commit a93cd20
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui/macutilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ void openFiles(const PathList &pathList)
for (const auto &path : pathList)
[pathURLs addObject:[NSURL fileURLWithPath:path.toString().toNSString()]];

[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:pathURLs];
// In some unknown way, the next line affects Qt's main loop causing the crash
// in QApplication::exec() on processing next event after this call.
// Even crash doesn't happen exactly after this call, it will happen on
// application exit. Call stack and disassembly are the same in all cases.
// But running it in another thread (aka in background) solves the issue.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:pathURLs];
});
}
}

Expand Down

0 comments on commit a93cd20

Please sign in to comment.