diff --git a/src/app/app.cpp b/src/app/app.cpp index d03fe77be..90caa59f6 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -146,6 +146,8 @@ App::App(int argc, const char* argv[]) // Load RenderEngine configuration RenderEngine::loadConfig(); + if (isPortable()) + PRINTF("Running in portable mode\n"); // Default palette. std::string palFile(!options.paletteFileName().empty() ? @@ -339,6 +341,14 @@ App::~App() } } +bool App::isPortable() +{ + std::string ini_file = get_config_file(); + app::ResourceFinder rf; + rf.includeBinDir("aseprite.ini"); + return (ini_file == rf.defaultFilename()); +} + tools::ToolBox* App::getToolBox() const { ASSERT(m_modules != NULL); diff --git a/src/app/app.h b/src/app/app.h index d0afb0b80..1e4286b9e 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -65,6 +65,9 @@ namespace app { // Returns true if Aseprite is running with GUI available. bool isGui() const { return m_isGui; } + // Returns true if the application is running in portable mode. + bool isPortable(); + // Runs the Aseprite application. In GUI mode it's the top-level // window, in console/scripting it just runs the specified scripts. int run(); diff --git a/src/app/send_crash.cpp b/src/app/send_crash.cpp index 9d178859d..a97de76dd 100644 --- a/src/app/send_crash.cpp +++ b/src/app/send_crash.cpp @@ -32,14 +32,29 @@ namespace app { -const char* SendCrash::kDefaultCrashName = "Aseprite-crash.dmp"; +static const char* kDefaultCrashName = "Aseprite-crash.dmp"; + +std::string memory_dump_filename() +{ +#ifdef WIN32 + + app::ResourceFinder rf; + if (App::instance()->isPortable()) + rf.includeBinDir(kDefaultCrashName); + else + rf.includeHomeDir(kDefaultCrashName); + + return rf.defaultFilename(); + +#else + return ""; +#endif +} void SendCrash::search() { #ifdef WIN32 - app::ResourceFinder rf; - rf.includeHomeDir(kDefaultCrashName); - m_dumpFilename = rf.defaultFilename(); + m_dumpFilename = memory_dump_filename(); if (base::is_file(m_dumpFilename)) { App::instance()->showNotification(this); diff --git a/src/app/send_crash.h b/src/app/send_crash.h index 23a5224f9..e1ea8fae9 100644 --- a/src/app/send_crash.h +++ b/src/app/send_crash.h @@ -28,8 +28,6 @@ namespace app { class SendCrash : public INotificationDelegate { public: - static const char* kDefaultCrashName; - void search(); virtual std::string notificationText() override; @@ -41,6 +39,8 @@ namespace app { std::string m_dumpFilename; }; + std::string memory_dump_filename(); + } // namespace app #endif // APP_SEND_CRASH_H_INCLUDED diff --git a/src/main/main.cpp b/src/main/main.cpp index a819d8e41..66e87a3ce 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -53,17 +53,6 @@ namespace { #endif }; - bool getMemoryDumpFilename(std::string& filename) { -#ifdef WIN32 - app::ResourceFinder rf; - rf.includeHomeDir(app::SendCrash::kDefaultCrashName); - filename = rf.defaultFilename(); - return true; -#else - return false; -#endif - } - } // Aseprite entry point. (Called from she library.) @@ -85,8 +74,8 @@ int app_main(int argc, char* argv[]) // Change the name of the memory dump file { - std::string filename; - if (getMemoryDumpFilename(filename)) + std::string filename = app::memory_dump_filename(); + if (!filename.empty()) memoryDump.setFileName(filename); }