forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
92 lines (77 loc) · 2.02 KB
/
main.cpp
File metadata and controls
92 lines (77 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Aseprite
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/app.h"
#include "app/app_options.h"
#include "app/console.h"
#include "app/resource_finder.h"
#include "app/send_crash.h"
#include "base/exception.h"
#include "base/memory.h"
#include "base/memory_dump.h"
#include "base/system_console.h"
#include "she/error.h"
#include "she/scoped_handle.h"
#include "she/system.h"
#include <clocale>
#include <cstdlib>
#include <ctime>
#include <iostream>
#ifdef _WIN32
#include <windows.h>
#endif
namespace {
// Memory leak detector wrapper
class MemLeak {
public:
#ifdef LAF_MEMLEAK
MemLeak() { base_memleak_init(); }
~MemLeak() { base_memleak_exit(); }
#else
MemLeak() { }
#endif
};
}
// Aseprite entry point. (Called from she library.)
int app_main(int argc, char* argv[])
{
// Initialize the locale. Aseprite isn't ready to handle numeric
// fields with other locales (e.g. we expect strings like "10.32" be
// used in std::strtod(), not something like "10,32").
std::setlocale(LC_ALL, "en-US");
ASSERT(std::strtod("10.32", nullptr) == 10.32);
// Initialize the random seed.
std::srand(static_cast<unsigned int>(std::time(nullptr)));
#ifdef _WIN32
::CoInitialize(NULL);
#endif
try {
base::MemoryDump memoryDump;
MemLeak memleak;
base::SystemConsole systemConsole;
app::AppOptions options(argc, const_cast<const char**>(argv));
she::ScopedHandle<she::System> system(she::create_system());
app::App app;
// Change the name of the memory dump file
{
std::string filename = app::memory_dump_filename();
if (!filename.empty())
memoryDump.setFileName(filename);
}
app.initialize(options);
if (options.startShell())
systemConsole.prepareShell();
app.run();
return 0;
}
catch (std::exception& e) {
std::cerr << e.what() << '\n';
she::error_message(e.what());
return 1;
}
}