[aseprite] 153/308: Load user brushes if the file exists and continue in case of error (fix #911)
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:04 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 5725b3bbf1b86787a3c76ddb6d25d9ec19bce7fc
Author: David Capello <davidcapello at gmail.com>
Date: Tue Dec 22 20:04:44 2015 -0300
Load user brushes if the file exists and continue in case of error (fix #911)
---
src/app/app.cpp | 4 ++++
src/app/app.h | 8 ++++++--
src/app/app_brushes.cpp | 10 +++++++++-
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 55d72f2..014f823 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -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;
diff --git a/src/app/app.h b/src/app/app.h
index ba1ae1c..14f3f6e 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -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();
diff --git a/src/app/app_brushes.cpp b/src/app/app_brushes.cpp
index 32efd11..7fea3e4 100644
--- a/src/app/app_brushes.cpp
+++ b/src/app/app_brushes.cpp
@@ -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()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list