Allow set_size() before set_parent()

REAPER does this.
This commit is contained in:
Robbert van der Helm
2022-10-10 17:38:57 +02:00
parent 0d5e2fc0d9
commit 19ee32039b
+11 -5
View File
@@ -514,22 +514,28 @@ void ClapBridge::run() {
[&, plugin = instance.plugin.get(),
gui = instance.extensions.gui,
&editor = instance.editor]() {
assert(editor);
// HACK: We need to resize the editor window before
// setting the size on the plugin. Surge XT and
// presumably other CLAP JUCE Extensions plugins
// will request a resize to the same size that was
// just set. This causes a resize loop, so we'll
// try to prevent resizes to the same size.
const Size old_size = editor->size();
editor->resize(request.width, request.height);
// The host is allowed to call this before
// `set_parent()`, so the editor instance may not
// yet exist.
Size old_size{};
if (editor) {
old_size = editor->size();
editor->resize(request.width, request.height);
}
if (gui->set_size(plugin, request.width,
request.height)) {
return true;
} else {
editor->resize(old_size.width, old_size.height);
if (editor) {
editor->resize(old_size.width, old_size.height);
}
return false;
}