Skip to content

Commit 2c20362

Browse files
committed
Fix JUCE app initialization in custom main()
Add forward declaration for juce_CreateApplication and set JUCEApplicationBase::createInstance before calling main(). This is required for JUCE to properly create the application instance. Previous commit caused segfaults because createInstance wasn't set. https://claude.ai/code/session_01AY9chvBEmsCVjNZSUkNcbw
1 parent 3ebb512 commit 2c20362

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Source/Main.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ class PluginValidatorApplication : public juce::JUCEApplication,
181181

182182
//==============================================================================
183183
#if PLUGINVAL_VST3_VALIDATOR
184+
// Forward declaration for JUCE application factory
185+
juce::JUCEApplicationBase* juce_CreateApplication();
186+
184187
// Custom main() to intercept --vst3-validator-mode before JUCE starts.
185188
// This avoids the "Periodic events are already being generated" crash on macOS
186189
// that occurs when JUCE's event loop conflicts with the validator subprocess.
@@ -220,11 +223,12 @@ int main (int argc, char* argv[])
220223
}
221224
}
222225

223-
// Normal JUCE application startup
226+
// Normal JUCE application startup - must set createInstance before calling main()
227+
juce::JUCEApplicationBase::createInstance = &juce_CreateApplication;
224228
return juce::JUCEApplicationBase::main (argc, const_cast<const char**> (argv));
225229
}
226230

227-
// Provide the JUCE application class
231+
// Provide the JUCE application class (required by JUCE's application framework)
228232
juce::JUCEApplicationBase* juce_CreateApplication() { return new PluginValidatorApplication(); }
229233

230234
#else

0 commit comments

Comments
 (0)