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