Create crash dump in aseprite folder when it's running in portable mode

This commit is contained in:
David Capello 2014-08-20 09:16:59 -03:00
parent 25ee4df7fb
commit 6559eab214
5 changed files with 36 additions and 19 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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

View File

@ -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);
}