summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2015-03-29 02:13:40 +1100
committernick_m <mainsbridge@gmail.com>2015-03-29 02:13:40 +1100
commit8962bfba619626bc1aa0a289e63d24576d428eeb (patch)
tree7bab3804124309442b546fccc1a3ce9526847fab
parent57e227fd52ce6e4711a4e105f294a155cffa222c (diff)
Better fix for 6183.
Invalidate all source entries from the image cache when we get our region's DropReferences signal, while ignoring any subsequent regions with no source.
-rw-r--r--libs/canvas/canvas/wave_view.h2
-rw-r--r--libs/canvas/wave_view.cc42
2 files changed, 33 insertions, 11 deletions
diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h
index 4b6d6c5627..9ace1486ce 100644
--- a/libs/canvas/canvas/wave_view.h
+++ b/libs/canvas/canvas/wave_view.h
@@ -163,6 +163,7 @@ private:
static std::map <boost::shared_ptr<ARDOUR::AudioSource>, std::vector <CacheEntry> > _image_cache;
void consolidate_image_cache () const;
+ void invalidate_source (boost::weak_ptr<ARDOUR::AudioSource>);
void invalidate_image_cache ();
boost::shared_ptr<ARDOUR::AudioRegion> _region;
@@ -188,6 +189,7 @@ private:
ARDOUR::frameoffset_t _region_start;
PBD::ScopedConnectionList invalidation_connection;
+ PBD::ScopedConnection _source_invalidated_connection;
static double _global_gradient_depth;
static bool _global_logscaled;
diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc
index 3521ef33cd..8570d8d32c 100644
--- a/libs/canvas/wave_view.cc
+++ b/libs/canvas/wave_view.cc
@@ -38,6 +38,8 @@
#include <gdkmm/general.h>
+#include "gtk2_ardour/gui_thread.h"
+
using namespace std;
using namespace ARDOUR;
using namespace ArdourCanvas;
@@ -74,6 +76,10 @@ WaveView::WaveView (Canvas* c, boost::shared_ptr<ARDOUR::AudioRegion> region)
, _start_shift (0.0)
, _region_start (region->start())
{
+ _region->DropReferences.connect (_source_invalidated_connection, MISSING_INVALIDATOR,
+ boost::bind (&ArdourCanvas::WaveView::invalidate_source,
+ this, boost::weak_ptr<AudioSource>(_region->audio_source())), gui_context());
+
VisualPropertiesChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_visual_property_change, this));
ClipLevelChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_clip_level_change, this));
}
@@ -97,12 +103,17 @@ WaveView::WaveView (Item* parent, boost::shared_ptr<ARDOUR::AudioRegion> region)
, _region_amplitude (_region->scale_amplitude ())
, _region_start (region->start())
{
+ _region->DropReferences.connect (_source_invalidated_connection, MISSING_INVALIDATOR,
+ boost::bind (&ArdourCanvas::WaveView::invalidate_source,
+ this, boost::weak_ptr<AudioSource>(_region->audio_source())), gui_context());
+
VisualPropertiesChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_visual_property_change, this));
ClipLevelChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_clip_level_change, this));
}
WaveView::~WaveView ()
{
+ _source_invalidated_connection.disconnect();
invalidate_image_cache ();
}
@@ -206,23 +217,32 @@ WaveView::set_clip_level (double dB)
}
void
-WaveView::invalidate_image_cache ()
+WaveView::invalidate_source (boost::weak_ptr<AudioSource> src)
{
- vector <uint32_t> deletion_list;
- vector <CacheEntry> caches;
+ if (boost::shared_ptr<AudioSource> source = src.lock()) {
- /* The source may have disappeared in the case of rec regions.*/
- if (_region->n_channels() == 0) {
std::map <boost::shared_ptr<ARDOUR::AudioSource>, std::vector <CacheEntry> >::iterator i;
- for (i = _image_cache.begin(); i != _image_cache.end(); ++i) {
- if (i->first.unique()) {
- for (uint32_t n = 0; n < (*i).second.size (); ++n) {
- (*i).second[n].image.clear ();
+ for (i = _image_cache.begin (); i != _image_cache.end (); ++i) {
+ if (i->first == source) {
+ for (uint32_t n = 0; n < i->second.size (); ++n) {
+ i->second[n].image.clear ();
}
- (*i).second.clear ();
- _image_cache.erase(i->first);
+ i->second.clear ();
+ _image_cache.erase (i->first);
}
}
+ }
+}
+
+void
+WaveView::invalidate_image_cache ()
+{
+ vector <uint32_t> deletion_list;
+ vector <CacheEntry> caches;
+
+ /* The source may have disappeared.*/
+
+ if (_region->n_channels() == 0) {
return;
}