|
@@ -26,16 +26,13 @@ namespace AzToolsFramework
|
|
|
ThumbnailerComponent::ThumbnailerComponent()
|
|
|
: m_missingThumbnail(new MissingThumbnail())
|
|
|
, m_loadingThumbnail(new LoadingThumbnail())
|
|
|
+ , m_placeholderObject(new QObject())
|
|
|
{
|
|
|
}
|
|
|
|
|
|
ThumbnailerComponent::~ThumbnailerComponent()
|
|
|
{
|
|
|
- ThumbnailerRequestBus::Handler::BusDisconnect();
|
|
|
- m_providers.clear();
|
|
|
- m_missingThumbnail.reset();
|
|
|
- m_loadingThumbnail.reset();
|
|
|
- m_thumbnailsBeingLoaded.clear();
|
|
|
+ Cleanup();
|
|
|
}
|
|
|
|
|
|
void ThumbnailerComponent::Activate()
|
|
@@ -45,11 +42,7 @@ namespace AzToolsFramework
|
|
|
|
|
|
void ThumbnailerComponent::Deactivate()
|
|
|
{
|
|
|
- ThumbnailerRequestBus::Handler::BusDisconnect();
|
|
|
- m_providers.clear();
|
|
|
- m_missingThumbnail.reset();
|
|
|
- m_loadingThumbnail.reset();
|
|
|
- m_thumbnailsBeingLoaded.clear();
|
|
|
+ Cleanup();
|
|
|
}
|
|
|
|
|
|
void ThumbnailerComponent::Reflect(AZ::ReflectContext* context)
|
|
@@ -130,25 +123,29 @@ namespace AzToolsFramework
|
|
|
// Connect thumbnailer component to the busy label repaint signal to notify the asset browser as it changes.
|
|
|
AzQtComponents::StyledBusyLabel* busyLabel = {};
|
|
|
AssetBrowser::AssetBrowserComponentRequestBus::BroadcastResult(busyLabel, &AssetBrowser::AssetBrowserComponentRequests::GetStyledBusyLabel);
|
|
|
- connect(busyLabel, &AzQtComponents::StyledBusyLabel::repaintNeeded, this, &ThumbnailerComponent::RepaintThumbnail);
|
|
|
+ QObject::connect(busyLabel, &AzQtComponents::StyledBusyLabel::repaintNeeded, m_placeholderObject.get(), [](){
|
|
|
+ AssetBrowser::AssetBrowserViewRequestBus::Broadcast(&AssetBrowser::AssetBrowserViewRequests::Update);
|
|
|
+ });
|
|
|
|
|
|
// The ThumbnailUpdated signal should be sent whenever the thumbnail has loaded or failed. In both cases,
|
|
|
// disconnect from all of the signals.
|
|
|
- connect(thumbnail.data(), &Thumbnail::ThumbnailUpdated, this, [this, key, thumbnail, busyLabel]()
|
|
|
+ QObject::connect(thumbnail.data(), &Thumbnail::ThumbnailUpdated, m_placeholderObject.get(), [this, key, thumbnail, busyLabel]()
|
|
|
{
|
|
|
- disconnect(busyLabel, nullptr, this, nullptr);
|
|
|
- disconnect(thumbnail.data(), &Thumbnail::ThumbnailUpdated, key.data(), &ThumbnailKey::ThumbnailUpdated);
|
|
|
+ QObject::disconnect(busyLabel, nullptr, m_placeholderObject.get(), nullptr);
|
|
|
+ QObject::disconnect(thumbnail.data(), nullptr, key.data(), nullptr);
|
|
|
+
|
|
|
+ QObject::connect(thumbnail.data(), &Thumbnail::ThumbnailUpdated, key.data(), &ThumbnailKey::ThumbnailUpdated);
|
|
|
+ QObject::connect(key.data(), &ThumbnailKey::ThumbnailUpdateRequested, thumbnail.data(), &Thumbnail::Update);
|
|
|
|
|
|
- connect(thumbnail.data(), &Thumbnail::ThumbnailUpdated, key.data(), &ThumbnailKey::ThumbnailUpdated);
|
|
|
- connect(key.data(), &ThumbnailKey::ThumbnailUpdateRequested, thumbnail.data(), &Thumbnail::Update);
|
|
|
key->SetReady(true);
|
|
|
m_thumbnailsBeingLoaded.erase(thumbnail);
|
|
|
+ AssetBrowser::AssetBrowserViewRequestBus::Broadcast(&AssetBrowser::AssetBrowserViewRequests::Update);
|
|
|
});
|
|
|
|
|
|
// Add the thumbnail to the set of thumbnails in progress then queue the job to load it. The job will send the
|
|
|
// ThumbnailUpdated signal from the main thread when complete.
|
|
|
m_thumbnailsBeingLoaded.insert(thumbnail);
|
|
|
- auto job = AZ::CreateJobFunction([thumbnail]() { thumbnail->Load(); }, true);
|
|
|
+ auto job = AZ::CreateJobFunction([thumbnail](){ thumbnail->Load(); }, true);
|
|
|
job->Start();
|
|
|
}
|
|
|
|
|
@@ -172,9 +169,15 @@ namespace AzToolsFramework
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- void ThumbnailerComponent::RepaintThumbnail()
|
|
|
+ void ThumbnailerComponent::Cleanup()
|
|
|
{
|
|
|
- AssetBrowser::AssetBrowserViewRequestBus::Broadcast(&AssetBrowser::AssetBrowserViewRequests::Update);
|
|
|
+ ThumbnailerRequestBus::Handler::BusDisconnect();
|
|
|
+
|
|
|
+ m_providers.clear();
|
|
|
+ m_missingThumbnail.reset();
|
|
|
+ m_loadingThumbnail.reset();
|
|
|
+ m_placeholderObject.reset();
|
|
|
+ m_thumbnailsBeingLoaded.clear();
|
|
|
}
|
|
|
} // namespace Thumbnailer
|
|
|
} // namespace AzToolsFramework
|