13
0

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.
This commit is contained in:
nick_m 2015-03-29 02:13:40 +11:00 committed by Paul Davis
parent cdc3e4970a
commit 7f187d4169
2 changed files with 33 additions and 11 deletions

View File

@ -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;

View File

@ -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 ();
}
@ -205,24 +216,33 @@ WaveView::set_clip_level (double dB)
}
}
void
WaveView::invalidate_source (boost::weak_ptr<AudioSource> src)
{
if (boost::shared_ptr<AudioSource> source = src.lock()) {
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 == source) {
for (uint32_t n = 0; n < i->second.size (); ++n) {
i->second[n].image.clear ();
}
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 in the case of rec regions.*/
/* The source may have disappeared.*/
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 ();
}
(*i).second.clear ();
_image_cache.erase(i->first);
}
}
return;
}