diff --git a/src/app/app.cpp b/src/app/app.cpp index aacf33e94..70d26f286 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -124,9 +124,10 @@ App::App() m_instance = this; } -void App::initialize(int argc, const char* argv[]) +void App::initialize(const AppOptions& options) { - AppOptions options(argc, argv); + if (options.startUI()) + m_guiSystem.reset(new ui::GuiSystem); // Initializes the application loading the modules, setting the // graphics mode, loading the configuration and resources, etc. diff --git a/src/app/app.h b/src/app/app.h index 9f9237bcf..32e05548a 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -33,8 +33,13 @@ namespace raster { class Layer; } +namespace ui { + class GuiSystem; +} + namespace app { + class AppOptions; class Document; class DocumentExporter; class INotificationDelegate; @@ -65,7 +70,7 @@ namespace app { // Runs the Aseprite application. In GUI mode it's the top-level // window, in console/scripting it just runs the specified // scripts. - void initialize(int argc, const char* argv[]); + void initialize(const AppOptions& options); void run(); tools::ToolBox* getToolBox() const; @@ -91,6 +96,7 @@ namespace app { static App* m_instance; base::SystemConsole m_systemConsole; + base::UniquePtr m_guiSystem; Modules* m_modules; LegacyModules* m_legacy; bool m_isGui; diff --git a/src/main/main.cpp b/src/main/main.cpp index 93968858e..794962c41 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -21,6 +21,7 @@ #endif #include "app/app.h" +#include "app/app_options.h" #include "app/console.h" #include "app/resource_finder.h" #include "app/send_crash.h" @@ -30,7 +31,6 @@ #include "she/error.h" #include "she/scoped_handle.h" #include "she/system.h" -#include "ui/base.h" #include #include @@ -67,9 +67,10 @@ int app_main(int argc, char* argv[]) try { base::MemoryDump memoryDump; - she::ScopedHandle system(she::create_system()); MemLeak memleak; - ui::GuiSystem guiSystem; + + app::AppOptions options(argc, const_cast(argv)); + she::ScopedHandle system(she::create_system()); app::App app; // Change the name of the memory dump file @@ -79,7 +80,7 @@ int app_main(int argc, char* argv[]) memoryDump.setFileName(filename); } - app.initialize(argc, const_cast(argv)); + app.initialize(options); app.run(); return 0; }