commit 142821521b704ea7852b673d64d282521e6ca3a6
parent 48f182ff46be49bdc1fea7406c2d5e94469f0b59
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Thu, 24 Oct 2024 01:21:34 +0200
prevent message boxes in headless mode / when juce loads the VST3/LV2 plugin during build
Diffstat:
5 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/source/jucePluginEditorLib/pluginEditor.cpp b/source/jucePluginEditorLib/pluginEditor.cpp
@@ -2,8 +2,9 @@
#include "pluginProcessor.h"
-#include "jucePluginLib/parameterbinding.h"
#include "jucePluginLib/clipboard.h"
+#include "jucePluginLib/parameterbinding.h"
+#include "jucePluginLib/tools.h"
#include "synthLib/os.h"
#include "synthLib/sysexToMidi.h"
@@ -212,6 +213,9 @@ namespace jucePluginEditorLib
void Editor::showDisclaimer() const
{
+ if(pluginLib::Tools::isHeadless())
+ return;
+
if(!m_processor.getConfig().getBoolValue("disclaimerSeen", false))
{
const juce::MessageBoxOptions options = juce::MessageBoxOptions::makeOptionsOk(juce::MessageBoxIconType::WarningIcon, m_processor.getProperties().name,
diff --git a/source/jucePluginLib/CMakeLists.txt b/source/jucePluginLib/CMakeLists.txt
@@ -28,6 +28,7 @@ set(SOURCES
pluginVersion.cpp pluginVersion.h
processor.cpp processor.h
softknob.cpp softknob.h
+ tools.cpp tools.h
types.h
version.h.in version.h
versionDateTime.h.in versionDateTime.h
diff --git a/source/jucePluginLib/processor.cpp b/source/jucePluginLib/processor.cpp
@@ -1,5 +1,6 @@
#include "processor.h"
#include "dummydevice.h"
+#include "tools.h"
#include "types.h"
#include "baseLib/binarystream.h"
@@ -106,7 +107,7 @@ namespace pluginLib
// Juce loads the LV2/VST3 versions of the plugin as part of the build process, if we open a message box in this case, the build process gets stuck
const auto host = juce::PluginHostType::getHostPath();
- if(!host.contains("juce_vst3_helper") && !host.contains("juce_lv2_helper"))
+ if(!Tools::isHeadless())
{
std::string msg = e.what();
diff --git a/source/jucePluginLib/tools.cpp b/source/jucePluginLib/tools.cpp
@@ -0,0 +1,21 @@
+#include "tools.h"
+
+#include "juce_audio_processors/juce_audio_processors.h"
+#include "juce_gui_basics/juce_gui_basics.h"
+
+namespace pluginLib
+{
+ bool Tools::isHeadless()
+ {
+ // returns false on a build machine without display even...
+ if(juce::Desktop::getInstance().isHeadless())
+ return true;
+
+ const auto host = juce::PluginHostType::getHostPath();
+
+ // So we use this instead. These tools cause crashes if you attempt to
+ // open a message box. LV2 even opens the editor, even on a headless
+ // build machine, whatever that is good for
+ return host.contains("juce_vst3_helper") || host.contains("juce_lv2_helper");
+ }
+}
diff --git a/source/jucePluginLib/tools.h b/source/jucePluginLib/tools.h
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace pluginLib
+{
+ class Tools
+ {
+ public:
+ static bool isHeadless();
+ };
+}