mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-16 19:21:12 +00:00
Don't use Preferences in background threads
This commit is contained in:
parent
686da0efd8
commit
673e1955fa
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -60,6 +60,7 @@ BackupObserver::BackupObserver(Session* session, Context* ctx)
|
||||
: m_session(session)
|
||||
, m_ctx(ctx)
|
||||
, m_done(false)
|
||||
, m_period(Preferences::instance().general.dataRecoveryPeriod())
|
||||
, m_thread(base::Bind<void>(&BackupObserver::backgroundThread, this))
|
||||
{
|
||||
m_ctx->add_observer(this);
|
||||
@ -97,7 +98,7 @@ void BackupObserver::onRemoveDocument(Doc* document)
|
||||
|
||||
void BackupObserver::backgroundThread()
|
||||
{
|
||||
int normalPeriod = int(60.0*Preferences::instance().general.dataRecoveryPeriod());
|
||||
int normalPeriod = int(60.0*m_period);
|
||||
int lockedPeriod = 5;
|
||||
#ifdef TEST_BACKUPS_WITH_A_SHORT_PERIOD
|
||||
normalPeriod = 5;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -42,6 +43,7 @@ namespace crash {
|
||||
Context* m_ctx;
|
||||
std::vector<Doc*> m_documents;
|
||||
bool m_done;
|
||||
int m_period;
|
||||
base::thread m_thread;
|
||||
};
|
||||
|
||||
|
@ -737,7 +737,7 @@ void FileOp::operate(IFileOpProgress* progress)
|
||||
|
||||
// For each frame in the sprite.
|
||||
render::Render render;
|
||||
render.setNewBlend(Preferences::instance().experimental.newBlend());
|
||||
render.setNewBlend(m_newBlend);
|
||||
|
||||
frame_t outputFrame = 0;
|
||||
for (frame_t frame : m_roi.selectedFrames()) {
|
||||
@ -913,7 +913,7 @@ void FileOp::postLoad()
|
||||
app::gen::ColorProfileBehavior behavior =
|
||||
app::gen::ColorProfileBehavior::DISABLE;
|
||||
|
||||
if (Preferences::instance().color.manage()) {
|
||||
if (m_preserveColorProfile) {
|
||||
// Embedded color profile
|
||||
if (this->hasEmbeddedColorProfile()) {
|
||||
behavior = Preferences::instance().color.filesWithProfile();
|
||||
@ -1186,9 +1186,9 @@ FileOp::FileOp(FileOpType type, Context* context)
|
||||
, m_oneframe(false)
|
||||
, m_createPaletteFromRgba(false)
|
||||
, m_ignoreEmpty(false)
|
||||
, m_preserveColorProfile(
|
||||
Preferences::instance().color.manage())
|
||||
, m_preserveColorProfile(Preferences::instance().color.manage())
|
||||
, m_embeddedColorProfile(false)
|
||||
, m_newBlend(Preferences::instance().experimental.newBlend())
|
||||
{
|
||||
m_seq.palette = nullptr;
|
||||
m_seq.image.reset();
|
||||
|
@ -208,6 +208,10 @@ namespace app {
|
||||
// True if the file contained a color profile when it was loaded.
|
||||
bool m_embeddedColorProfile;
|
||||
|
||||
// True if we should render each frame to save it with the new
|
||||
// blend mode.
|
||||
bool m_newBlend;
|
||||
|
||||
base::SharedPtr<FormatOptions> m_formatOptions;
|
||||
|
||||
// Data for sequences.
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "app/tools/tool.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "os/system.h"
|
||||
#include "ui/system.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -25,6 +26,10 @@ static Preferences* singleton = nullptr;
|
||||
// static
|
||||
Preferences& Preferences::instance()
|
||||
{
|
||||
// Preferences can be used only from the main UI thread. In other
|
||||
// case access to std::map<> could crash the program.
|
||||
ui::assert_ui_thread();
|
||||
|
||||
ASSERT(singleton);
|
||||
return *singleton;
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ private:
|
||||
// Load the file
|
||||
m_fop->operate(nullptr);
|
||||
|
||||
// Post load
|
||||
m_fop->postLoad();
|
||||
// Don't call post-load because postLoad() needs user interaction.
|
||||
//m_fop->postLoad();
|
||||
|
||||
// Convert the loaded document into the os::Surface.
|
||||
const Sprite* sprite =
|
||||
|
Loading…
x
Reference in New Issue
Block a user