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;
ARDOUR::frameoffset_t _region_start;
PBD::ScopedConnectionList invalidation_connection;
+ PBD::ScopedConnection _source_invalidated_connection;
static double _global_gradient_depth;
static bool _global_logscaled;
#include <gdkmm/general.h>
+#include "gtk2_ardour/gui_thread.h"
+
using namespace std;
using namespace ARDOUR;
using namespace ArdourCanvas;
, _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));
}
, _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 ();
}
}
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;
}