mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-21 03:40:57 +00:00
Load user brushes if the file exists and continue in case of error (fix #911)
This commit is contained in:
parent
ff507af308
commit
5725b3bbf1
@ -163,6 +163,7 @@ void App::initialize(const AppOptions& options)
|
||||
m_coreModules = new CoreModules;
|
||||
m_modules = new Modules(options.verbose());
|
||||
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
||||
m_brushes.reset(new AppBrushes);
|
||||
|
||||
if (options.hasExporterParams())
|
||||
m_exporter.reset(new DocumentExporter);
|
||||
@ -673,6 +674,9 @@ App::~App()
|
||||
// Finalize modules, configuration and core.
|
||||
Editor::destroyEditorSharedInternals();
|
||||
|
||||
// Save brushes
|
||||
m_brushes.reset(nullptr);
|
||||
|
||||
delete m_legacy;
|
||||
delete m_modules;
|
||||
delete m_coreModules;
|
||||
|
@ -70,7 +70,11 @@ namespace app {
|
||||
RecentFiles* getRecentFiles() const;
|
||||
MainWindow* getMainWindow() const { return m_mainWindow; }
|
||||
Preferences& preferences() const;
|
||||
AppBrushes& brushes() { return m_brushes; }
|
||||
|
||||
AppBrushes& brushes() {
|
||||
ASSERT(m_brushes.get());
|
||||
return *m_brushes;
|
||||
}
|
||||
|
||||
void showNotification(INotificationDelegate* del);
|
||||
void updateDisplayTitleBar();
|
||||
@ -97,7 +101,7 @@ namespace app {
|
||||
base::UniquePtr<MainWindow> m_mainWindow;
|
||||
FileList m_files;
|
||||
base::UniquePtr<DocumentExporter> m_exporter;
|
||||
AppBrushes m_brushes;
|
||||
base::UniquePtr<AppBrushes> m_brushes;
|
||||
};
|
||||
|
||||
void app_refresh_screen();
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "app/xml_exception.h"
|
||||
#include "base/base64.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/path.h"
|
||||
#include "base/serialization.h"
|
||||
#include "doc/brush.h"
|
||||
@ -168,7 +169,14 @@ AppBrushes::AppBrushes()
|
||||
m_standard.push_back(BrushRef(new Brush(kSquareBrushType, 7, 0)));
|
||||
m_standard.push_back(BrushRef(new Brush(kLineBrushType, 7, 44)));
|
||||
|
||||
load(userBrushesFilename());
|
||||
try {
|
||||
std::string fn = userBrushesFilename();
|
||||
if (base::is_file(fn))
|
||||
load(fn);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
LOG("Error loading user brushes: %s", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
AppBrushes::~AppBrushes()
|
||||
|
Loading…
x
Reference in New Issue
Block a user