diff --git a/include/Engine.h b/include/Engine.h index 322f109c9..5106222dc 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -53,13 +53,10 @@ class ControllerRackView; class EXPORT Engine { public: - static void init( const bool _has_gui = true ); + static void init(); static void destroy(); - static bool hasGUI() - { - return s_hasGUI; - } + static bool hasGUI(); static void setSuppressMessages( bool _on ) { @@ -68,7 +65,7 @@ public: static bool suppressMessages() { - return !s_hasGUI || s_suppressMessages; + return !hasGUI() || s_suppressMessages; } // core @@ -130,7 +127,6 @@ private: delete tmp; } - static bool s_hasGUI; static bool s_suppressMessages; static float s_framesPerTick; @@ -149,7 +145,7 @@ private: static void initPluginFileHandling(); friend class GuiApplication; -} ; +}; diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index e569e612e..cbe826bed 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -38,8 +38,9 @@ #include "Song.h" #include "BandLimitedWave.h" +#include "GuiApplication.h" + -bool Engine::s_hasGUI = true; bool Engine::s_suppressMessages = false; float Engine::s_framesPerTick; Mixer* Engine::s_mixer = NULL; @@ -54,10 +55,8 @@ QMap Engine::s_pluginFileHandling; -void Engine::init( const bool _has_gui ) +void Engine::init() { - s_hasGUI = _has_gui; - // generate (load from file) bandlimited wavetables BandLimitedWave::generateWaves(); @@ -109,6 +108,11 @@ void Engine::destroy() delete ConfigManager::inst(); } +bool Engine::hasGUI() +{ + return gui != nullptr; +} + diff --git a/src/core/main.cpp b/src/core/main.cpp index cfa7ae5d0..d3f98d909 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -485,7 +485,7 @@ int main( int argc, char * * argv ) else { // we're going to render our song - Engine::init( false ); + Engine::init(); printf( "loading project...\n" ); Engine::getSong()->loadProject( file_to_load ); diff --git a/src/gui/GuiApplication.cpp b/src/gui/GuiApplication.cpp index 5801e52f6..78cf609ef 100644 --- a/src/gui/GuiApplication.cpp +++ b/src/gui/GuiApplication.cpp @@ -51,8 +51,6 @@ GuiApplication* GuiApplication::instance() GuiApplication::GuiApplication() { - s_instance = this; - // Init style and palette LmmsStyle* lmmsstyle = new LmmsStyle(); QApplication::setStyle(lmmsstyle); @@ -71,7 +69,9 @@ GuiApplication::GuiApplication() qApp->processEvents(); // Init central engine which handles all components of LMMS - Engine::init(false); + Engine::init(); + + s_instance = this; m_mainWindow = new MainWindow; @@ -85,11 +85,10 @@ GuiApplication::GuiApplication() m_mainWindow->finalize(); splashScreen.finish(m_mainWindow); - - Engine::s_hasGUI = true; } GuiApplication::~GuiApplication() { InstrumentTrackView::cleanupWindowCache(); + s_instance = nullptr; }