From 53ea1843abdab0680156b4a9d9ceb5fb5e431a9c Mon Sep 17 00:00:00 2001 From: Nick Korotysh Date: Fri, 1 Jul 2022 23:07:02 +0200 Subject: [PATCH 1/2] Pass Torrent::contentPath() to MacUtils::openFiles() it already provides absolute path, no additional manipulations are required. --- src/gui/transferlistwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index af40bd6b6..9d17d9a9d 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -552,7 +552,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const // folders prehilighted for opening, so we use a custom method. for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents())) { - const Path contentPath = torrent->actualStorageLocation() / torrent->contentPath(); + const Path contentPath = torrent->contentPath(); paths.insert(contentPath); } MacUtils::openFiles(PathList(paths.cbegin(), paths.cend())); From a93cd20e4d2ecee91d51c9c55e0939038d7c7992 Mon Sep 17 00:00:00 2001 From: Nick Korotysh Date: Fri, 1 Jul 2022 23:09:37 +0200 Subject: [PATCH 2/2] Open destination folders on macOS in separate thread 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. --- src/gui/macutilities.mm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/macutilities.mm b/src/gui/macutilities.mm index e9ca0fe5a..823a1daa9 100644 --- a/src/gui/macutilities.mm +++ b/src/gui/macutilities.mm @@ -106,7 +106,15 @@ namespace MacUtils 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]; + }); } }