mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +00:00
Move some App members (ConfigModule/CheckArgs/LoggerModule) to App::Modules
This commit is contained in:
parent
810b082500
commit
408f54e509
38
src/app.cpp
38
src/app.cpp
@ -59,7 +59,6 @@
|
||||
#include "widgets/editor/editor.h"
|
||||
#include "widgets/editor/editor_view.h"
|
||||
#include "widgets/main_window.h"
|
||||
#include "widgets/menuitem2.h"
|
||||
#include "widgets/status_bar.h"
|
||||
#include "widgets/tabs.h"
|
||||
#include "widgets/toolbar.h"
|
||||
@ -82,6 +81,9 @@ using namespace ui;
|
||||
class App::Modules
|
||||
{
|
||||
public:
|
||||
ConfigModule m_configModule;
|
||||
CheckArgs m_checkArgs;
|
||||
LoggerModule m_loggerModule;
|
||||
FileSystemModule m_file_system_module;
|
||||
tools::ToolBox m_toolbox;
|
||||
CommandsModule m_commands_modules;
|
||||
@ -89,8 +91,10 @@ public:
|
||||
RecentFiles m_recent_files;
|
||||
app::DataRecovery m_recovery;
|
||||
|
||||
Modules()
|
||||
: m_recovery(&m_ui_context) {
|
||||
Modules(const std::vector<base::string>& args)
|
||||
: m_checkArgs(args)
|
||||
, m_loggerModule(m_checkArgs.isVerbose())
|
||||
, m_recovery(&m_ui_context) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -101,10 +105,7 @@ static char *palette_filename = NULL;
|
||||
// Initializes the application loading the modules, setting the
|
||||
// graphics mode, loading the configuration and resources, etc.
|
||||
App::App(int argc, char* argv[])
|
||||
: m_configModule(NULL)
|
||||
, m_checkArgs(NULL)
|
||||
, m_loggerModule(NULL)
|
||||
, m_modules(NULL)
|
||||
: m_modules(NULL)
|
||||
, m_legacy(NULL)
|
||||
, m_isGui(false)
|
||||
{
|
||||
@ -114,11 +115,8 @@ App::App(int argc, char* argv[])
|
||||
for (int i = 0; i < argc; ++i)
|
||||
m_args.push_back(argv[i]);
|
||||
|
||||
m_configModule = new ConfigModule();
|
||||
m_checkArgs = new CheckArgs(m_args);
|
||||
m_loggerModule = new LoggerModule(m_checkArgs->isVerbose());
|
||||
m_modules = new Modules();
|
||||
m_isGui = !(m_checkArgs->isConsoleOnly());
|
||||
m_modules = new Modules(m_args);
|
||||
m_isGui = !(m_modules->m_checkArgs.isConsoleOnly());
|
||||
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
||||
|
||||
// Register well-known image file types.
|
||||
@ -173,12 +171,12 @@ int App::run()
|
||||
// Procress options
|
||||
PRINTF("Processing options...\n");
|
||||
|
||||
ASSERT(m_checkArgs != NULL);
|
||||
{
|
||||
Console console;
|
||||
for (CheckArgs::iterator
|
||||
it = m_checkArgs->begin();
|
||||
it != m_checkArgs->end(); ++it) {
|
||||
it = m_modules->m_checkArgs.begin(),
|
||||
end = m_modules->m_checkArgs.end();
|
||||
it != end; ++it) {
|
||||
CheckArgs::Option* option = *it;
|
||||
|
||||
switch (option->type()) {
|
||||
@ -208,8 +206,6 @@ int App::run()
|
||||
}
|
||||
}
|
||||
}
|
||||
delete m_checkArgs;
|
||||
m_checkArgs = NULL;
|
||||
}
|
||||
|
||||
// Run the GUI
|
||||
@ -254,8 +250,6 @@ App::~App()
|
||||
|
||||
delete m_legacy;
|
||||
delete m_modules;
|
||||
delete m_loggerModule;
|
||||
delete m_configModule;
|
||||
|
||||
// Destroy the loaded gui.xml file.
|
||||
delete GuiXml::instance();
|
||||
@ -269,12 +263,6 @@ App::~App()
|
||||
}
|
||||
}
|
||||
|
||||
LoggerModule* App::getLogger() const
|
||||
{
|
||||
ASSERT(m_loggerModule != NULL);
|
||||
return m_loggerModule;
|
||||
}
|
||||
|
||||
tools::ToolBox* App::getToolBox() const
|
||||
{
|
||||
ASSERT(m_modules != NULL);
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class CheckArgs;
|
||||
class ConfigModule;
|
||||
class Document;
|
||||
class Layer;
|
||||
class LegacyModules;
|
||||
@ -63,7 +61,6 @@ public:
|
||||
// window, in console/scripting it just runs the specified scripts.
|
||||
int run();
|
||||
|
||||
LoggerModule* getLogger() const;
|
||||
tools::ToolBox* getToolBox() const;
|
||||
RecentFiles* getRecentFiles() const;
|
||||
MainWindow* getMainWindow() const { return m_mainWindow; }
|
||||
@ -80,9 +77,6 @@ private:
|
||||
|
||||
static App* m_instance;
|
||||
|
||||
ConfigModule* m_configModule;
|
||||
CheckArgs* m_checkArgs;
|
||||
LoggerModule* m_loggerModule;
|
||||
Modules* m_modules;
|
||||
LegacyModules* m_legacy;
|
||||
bool m_isGui;
|
||||
|
12
src/log.cpp
12
src/log.cpp
@ -47,9 +47,13 @@ static std::string log_filename;
|
||||
static FILE *log_fileptr = NULL;
|
||||
#endif
|
||||
|
||||
static LoggerModule* logger_instance = NULL;
|
||||
|
||||
LoggerModule::LoggerModule(bool verbose)
|
||||
: m_verbose(verbose)
|
||||
{
|
||||
logger_instance = this;
|
||||
|
||||
#ifdef NEED_LOG
|
||||
ResourceFinder rf;
|
||||
rf.findInBinDir("aseprite.log");
|
||||
@ -67,13 +71,15 @@ LoggerModule::~LoggerModule()
|
||||
log_fileptr = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
logger_instance = NULL;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void verbose_printf(const char *format, ...)
|
||||
void verbose_printf(const char* format, ...)
|
||||
{
|
||||
if (!App::instance()) {
|
||||
if (!logger_instance) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(stderr, format, ap);
|
||||
@ -82,7 +88,7 @@ void verbose_printf(const char *format, ...)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!App::instance()->getLogger()->isVerbose())
|
||||
if (!logger_instance->isVerbose())
|
||||
return;
|
||||
|
||||
#ifdef NEED_LOG
|
||||
|
Loading…
x
Reference in New Issue
Block a user