File check-for-display.patch of Package monique-monosynth
diff --git a/src/ui/monique_ui_MainWindow.cpp b/src/ui/monique_ui_MainWindow.cpp
index e26b67b..09acdac 100644
--- a/src/ui/monique_ui_MainWindow.cpp
+++ b/src/ui/monique_ui_MainWindow.cpp
@@ -1333,27 +1333,31 @@ void resize_component_to_host_display(juce::Component &component,
const auto host_display = get_host_display(component);
const auto &user_area = host_display->userArea;
- auto height = original_bounds.getHeight() * wanted_scale;
- auto width = original_bounds.getWidth() * wanted_scale;
-
- const auto host_height = host_display->userArea.getHeight();
- const auto host_width = user_area.getWidth();
- if (host_height < height)
+ if (host_display != nullptr)
{
- height = host_height * 0.9;
- float shrink_to_height_scale = 1.0f / original_bounds.getHeight() * height;
- width = original_bounds.getWidth() * shrink_to_height_scale;
- }
+ auto height = original_bounds.getHeight() * wanted_scale;
+ auto width = original_bounds.getWidth() * wanted_scale;
- if (host_width < width)
- {
- width = host_height * 0.9;
- float shrink_to_with_scale = 1.0f / original_bounds.getWidth() * width;
- width = original_bounds.getWidth() * shrink_to_with_scale;
- height = original_bounds.getHeight() * shrink_to_with_scale;
- }
+ const auto host_height = host_display->userArea.getHeight();
+ const auto host_width = user_area.getWidth();
+ if (host_height < height)
+ {
+ height = host_height * 0.9;
+ float shrink_to_height_scale = 1.0f / original_bounds.getHeight() * height;
+ width = original_bounds.getWidth() * shrink_to_height_scale;
+ }
- component.setSize(width, height);
+
+ if (host_width < width)
+ {
+ width = host_height * 0.9;
+ float shrink_to_with_scale = 1.0f / original_bounds.getWidth() * width;
+ width = original_bounds.getWidth() * shrink_to_with_scale;
+ height = original_bounds.getHeight() * shrink_to_with_scale;
+ }
+
+ component.setSize(width, height);
+ }
}
/**