summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorNick Dedekind <nicholas.dedekind@gmail.com>2012-08-21 12:16:56 -0400
committerTarmac <>2012-08-21 12:16:56 -0400
commit5993c89ac791f79abbb05f29684ced22b209bcb9 (patch)
treea4117de039bb364e688b7e3703427f329e95d0a2 /unity-shared
parent5db1fa32a118422e8cd50bc622d8897147764657 (diff)
parent3a973aea53a25dd4938e7cd9f9ba5ac37bf921c3 (diff)
Stopped previews with no image or image source uri logging warning messages from the thumbnail generator.. Fixes: . Approved by Michal Hruby.
(bzr r2601)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/CoverArt.cpp38
-rw-r--r--unity-shared/CoverArt.h4
-rw-r--r--unity-shared/ThumbnailGenerator.cpp3
3 files changed, 29 insertions, 16 deletions
diff --git a/unity-shared/CoverArt.cpp b/unity-shared/CoverArt.cpp
index c6949d499..e7957e58d 100644
--- a/unity-shared/CoverArt.cpp
+++ b/unity-shared/CoverArt.cpp
@@ -126,11 +126,18 @@ void CoverArt::SetImage(std::string const& image_hint)
void CoverArt::GenerateImage(std::string const& uri)
{
- StartWaiting();
notifier_ = ThumbnailGenerator::Instance().GetThumbnail(uri, 512);
-
- notifier_->ready.connect(sigc::mem_fun(this, &CoverArt::OnThumbnailGenerated));
- notifier_->error.connect(sigc::mem_fun(this, &CoverArt::OnThumbnailError));
+ if (notifier_)
+ {
+ StartWaiting();
+ notifier_->ready.connect(sigc::mem_fun(this, &CoverArt::OnThumbnailGenerated));
+ notifier_->error.connect(sigc::mem_fun(this, &CoverArt::OnThumbnailError));
+ }
+ else
+ {
+ StopWaiting();
+ SetNoImageAvailable();
+ }
}
void CoverArt::StartWaiting()
@@ -145,9 +152,9 @@ void CoverArt::StartWaiting()
spinner_timeout_.reset(new glib::TimeoutSeconds(5, [&]
{
- texture_screenshot_.Release();
- waiting_ = false;
+ StopWaiting();
+ texture_screenshot_.Release();
SetNoImageAvailable();
return false;
}));
@@ -155,6 +162,13 @@ void CoverArt::StartWaiting()
QueueDraw();
}
+void CoverArt::StopWaiting()
+{
+ spinner_timeout_.reset();
+ frame_timeout_.reset();
+ waiting_ = false;
+}
+
void CoverArt::SetNoImageAvailable()
{
if (GetLayout())
@@ -170,9 +184,7 @@ void CoverArt::SetNoImageAvailable()
void CoverArt::IconLoaded(std::string const& texid, unsigned size, glib::Object<GdkPixbuf> const& pixbuf)
{
// Finished waiting
- spinner_timeout_.reset();
- frame_timeout_.reset();
- waiting_ = false;
+ StopWaiting();
stretch_image_ = false;
if (!pixbuf)
@@ -251,9 +263,7 @@ void CoverArt::IconLoaded(std::string const& texid, unsigned size, glib::Object<
void CoverArt::TextureLoaded(std::string const& texid, unsigned size, glib::Object<GdkPixbuf> const& pixbuf)
{
// Finished waiting
- spinner_timeout_.reset();
- frame_timeout_.reset();
- waiting_ = false;
+ StopWaiting();
stretch_image_ = true;
if (!pixbuf)
@@ -425,9 +435,7 @@ void CoverArt::OnThumbnailGenerated(std::string const& uri)
void CoverArt::OnThumbnailError(std::string const& error_hint)
{
LOG_WARNING(logger) << "Failed to generate thumbnail: " << error_hint;
- spinner_timeout_.reset();
- frame_timeout_.reset();
- waiting_ = false;
+ StopWaiting();
texture_screenshot_.Release();
if (GetLayout())
diff --git a/unity-shared/CoverArt.h b/unity-shared/CoverArt.h
index dd5a666fe..0fd817aff 100644
--- a/unity-shared/CoverArt.h
+++ b/unity-shared/CoverArt.h
@@ -52,6 +52,8 @@ public:
void SetImage(std::string const& image_hint);
// Use for generating an image for a uri which is not necessarily an image.
void GenerateImage(std::string const& uri);
+
+ void SetNoImageAvailable();
// From debug::Introspectable
std::string GetName() const;
@@ -72,7 +74,7 @@ protected:
void TextureLoaded(std::string const& texid, unsigned size, glib::Object<GdkPixbuf> const& pixbuf);
void StartWaiting();
- void SetNoImageAvailable();
+ void StopWaiting();
private:
nux::ObjectPtr<nux::BaseTexture> texture_screenshot_;
diff --git a/unity-shared/ThumbnailGenerator.cpp b/unity-shared/ThumbnailGenerator.cpp
index c65f99ea0..a214afa07 100644
--- a/unity-shared/ThumbnailGenerator.cpp
+++ b/unity-shared/ThumbnailGenerator.cpp
@@ -457,6 +457,9 @@ ThumbnailGenerator& ThumbnailGenerator::Instance()
ThumbnailNotifier::Ptr ThumbnailGenerator::GetThumbnail(std::string const& uri, int size)
{
+ if (uri.empty())
+ return ThumbnailNotifier::Ptr();
+
return pimpl->GetThumbnail(uri, size);
}