Fix STA thread blocking crash on album art loading

Replace async GetFileFromPathAsync().get() with synchronous CreateFromUri() to avoid blocking STA thread. This prevents the "sta thread blocking wait" assertion failure.

Co-authored-by: jonaski <10343810+jonaski@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-28 21:51:28 +00:00
parent 4da4c9e267
commit d2afa8fd66

View File

@@ -50,6 +50,7 @@
#include "covermanager/albumcoverloaderresult.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Media;
using namespace Windows::Storage;
using namespace Windows::Storage::Streams;
@@ -279,8 +280,10 @@ void WindowsMediaController::UpdateMetadata(const Song &song, const QUrl &art_ur
QString artPath = art_url.toLocalFile();
if (!artPath.isEmpty()) {
try {
auto thumbnailStream = RandomAccessStreamReference::CreateFromFile(
StorageFile::GetFileFromPathAsync(winrt::hstring(artPath.toStdWString())).get()
// Use file:// URI to avoid async blocking in STA thread
QString fileUri = QUrl::fromLocalFile(artPath).toString();
auto thumbnailStream = RandomAccessStreamReference::CreateFromUri(
winrt::Windows::Foundation::Uri(winrt::hstring(fileUri.toStdWString()))
);
updater.Thumbnail(thumbnailStream);
current_song_art_url_ = artPath;