Ignore idempotent set_name() calls

These calls are expensive, particularly for ArdourButton, that
triggers a re-layout.
This commit is contained in:
Robin Gareus 2020-05-12 15:37:23 +02:00
parent 7b2b2401a3
commit ab6e274613
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 16 additions and 1 deletions

View File

@ -55,8 +55,9 @@ CairoWidget::CairoWidget ()
, _current_parent (0)
, _canvas_widget (false)
, _nsglview (0)
, _widget_name ("")
{
_name_proxy.connect (sigc::mem_fun (*this, &CairoWidget::on_name_changed));
_name_proxy.connect (sigc::mem_fun (*this, &CairoWidget::on_widget_name_changed));
#ifdef USE_CAIRO_IMAGE_SURFACE
_use_image_surface = true;
#else
@ -461,3 +462,14 @@ CairoWidget::set_focus_handler (sigc::slot<void,Gtk::Widget*> s)
{
focus_handler = s;
}
void
CairoWidget::on_widget_name_changed ()
{
Glib::ustring name = get_name();
if (_widget_name == name) {
return;
}
_widget_name = name;
on_name_changed ();
}

View File

@ -143,6 +143,8 @@ protected:
static sigc::slot<void,Gtk::Widget*> focus_handler;
private:
void on_widget_name_changed ();
Cairo::RefPtr<Cairo::Surface> image_surface;
Glib::SignalProxyProperty _name_proxy;
sigc::connection _parent_style_change;
@ -151,6 +153,7 @@ private:
void* _nsglview;
bool _use_image_surface;
Gdk::Rectangle _allocation;
Glib::ustring _widget_name;
};