Fix crash when changing UI scale on Windows

When the UI scale changes without the Recorder UI being shown
at least once, the Widgets have not yet been realized, size-groups
not evaluated, and a widget size of 1x1 is assumed.
This commit is contained in:
Robin Gareus 2021-08-10 04:15:15 +02:00
parent 738d36b5b7
commit fb8112eb7e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 17 additions and 3 deletions

View File

@ -241,6 +241,15 @@ InputPortMonitor::InputScope::InputScope (samplecnt_t rate, int l, int g, Orient
parameter_changed ("waveform-clip-level"); parameter_changed ("waveform-clip-level");
parameter_changed ("show-waveform-clipping"); parameter_changed ("show-waveform-clipping");
parameter_changed ("waveform-scale"); parameter_changed ("waveform-scale");
UIConfiguration::instance().DPIReset.connect (sigc::mem_fun (*this, &InputPortMonitor::InputScope::dpi_reset));
}
void
InputPortMonitor::InputScope::dpi_reset ()
{
if (is_realized ()) {
queue_resize ();
}
} }
void void
@ -282,7 +291,7 @@ InputPortMonitor::InputScope::on_size_allocate (Gtk::Allocation& a)
} }
if (a.get_width () != w || a.get_height () != h) { if (a.get_width () != w || a.get_height () != h) {
_surface = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, a.get_width () - 2, a.get_height () - 2); _surface = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, std::max (1, a.get_width () - 2), std::max (1, a.get_height () - 2));
} }
} }
@ -444,8 +453,10 @@ InputPortMonitor::EventMeter::dpi_reset ()
_layout->get_pixel_size (_length, _extent); _layout->get_pixel_size (_length, _extent);
_extent += 2; _extent += 2;
_length += 2; _length += 2;
if (is_realized ()) {
queue_resize (); queue_resize ();
} }
}
void void
InputPortMonitor::EventMeter::on_size_request (Gtk::Requisition* req) InputPortMonitor::EventMeter::on_size_request (Gtk::Requisition* req)
@ -551,8 +562,10 @@ InputPortMonitor::EventMonitor::dpi_reset ()
_layout->get_pixel_size (_width, _height); _layout->get_pixel_size (_width, _height);
_width += 2; _width += 2;
_height += 2; _height += 2;
if (is_realized ()) {
queue_resize (); queue_resize ();
} }
}
void void
InputPortMonitor::EventMonitor::on_size_request (Gtk::Requisition* req) InputPortMonitor::EventMonitor::on_size_request (Gtk::Requisition* req)

View File

@ -64,6 +64,7 @@ private:
void on_size_allocate (Gtk::Allocation&); void on_size_allocate (Gtk::Allocation&);
private: private:
void dpi_reset ();
int _pos; int _pos;
ARDOUR::samplecnt_t _rate; ARDOUR::samplecnt_t _rate;