Skip to content

Commit

Permalink
Now ContextWriter will always wait 1/2 second to unlock the backup th…
Browse files Browse the repository at this point in the history
…read
  • Loading branch information
dacap committed Feb 5, 2020
1 parent d316781 commit df74444
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/app/commands/cmd_add_color.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -116,7 +116,7 @@ void AddColorCommand::onExecute(Context* ctx)
if (index >= 0)
return;

ContextWriter writer(ctx, 500);
ContextWriter writer(ctx);
Doc* document(writer.document());
Sprite* sprite = writer.sprite();
if (!document || !sprite) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/commands/cmd_grid.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -69,7 +69,7 @@ class SelectionAsGridCommand : public Command {
}

void onExecute(Context* ctx) override {
ContextWriter writer(ctx, 500);
ContextWriter writer(ctx);
Doc* doc = writer.document();
const Mask* mask = doc->mask();
gfx::Rect newGrid = mask->bounds();
Expand Down Expand Up @@ -125,7 +125,7 @@ void GridSettingsCommand::onExecute(Context* context)
bounds.w = std::max(bounds.w, 1);
bounds.h = std::max(bounds.h, 1);

ContextWriter writer(context, 500);
ContextWriter writer(context);
Tx tx(context, friendlyName(), ModifyDocument);
tx(new cmd::SetGridBounds(site.sprite(), bounds));
tx.commit();
Expand Down
4 changes: 2 additions & 2 deletions src/app/commands/cmd_new_brush.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -111,7 +111,7 @@ void NewBrushCommand::onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::M
// If the right-button was used, we clear the selected area.
if (buttons & ui::kButtonRight) {
try {
ContextWriter writer(UIContext::instance(), 250);
ContextWriter writer(UIContext::instance());
if (writer.cel()) {
gfx::Rect canvasRect = (rect & writer.cel()->bounds());
if (!canvasRect.isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/commands/cmd_options.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -592,7 +592,7 @@ class OptionsWindow : public app::gen::Options {

// Change sprite grid bounds
if (m_context && m_context->activeDocument()) {
ContextWriter writer(m_context, 500);
ContextWriter writer(m_context);
Tx tx(m_context, Strings::commands_GridSettings(), ModifyDocument);
tx(new cmd::SetGridBounds(writer.sprite(), gridBounds()));
tx.commit();
Expand Down
4 changes: 2 additions & 2 deletions src/app/commands/cmd_remove_slice.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -96,7 +96,7 @@ void RemoveSliceCommand::onExecute(Context* context)
}

{
ContextWriter writer(reader, 500);
ContextWriter writer(reader);
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
Tx tx(writer.context(), "Remove Slice");
Expand Down
4 changes: 2 additions & 2 deletions src/app/commands/cmd_slice_properties.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -90,7 +90,7 @@ void SlicePropertiesCommand::onExecute(Context* context)

{
const SliceWindow::Mods mods = window.modifiedFields();
ContextWriter writer(reader, 500);
ContextWriter writer(reader);
Tx tx(writer.context(), "Slice Properties");

for (Slice* slice : slices.iterateAs<Slice>()) {
Expand Down
5 changes: 3 additions & 2 deletions src/app/context_access.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -78,11 +79,11 @@ namespace app {
// active document.
class ContextWriter : public ContextAccess<DocWriter> {
public:
ContextWriter(const Context* context, int timeout = 0)
ContextWriter(const Context* context, int timeout = 500)
: ContextAccess<DocWriter>(context, timeout) {
}

ContextWriter(const ContextReader& reader, int timeout = 0)
ContextWriter(const ContextReader& reader, int timeout = 500)
: ContextAccess<DocWriter>(reader.context(), reader.document(), timeout) {
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/app/doc_range_ops.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -332,7 +332,7 @@ static DocRange drop_range_op(
{
const app::Context* context = static_cast<app::Context*>(doc->context());
const ContextReader reader(context);
ContextWriter writer(reader, 500);
ContextWriter writer(reader);
Tx tx(writer.context(), undoLabel, ModifyDocument);
DocApi api = doc->getApi(tx);

Expand Down Expand Up @@ -489,7 +489,7 @@ void reverse_frames(Doc* doc, const DocRange& range)
{
const app::Context* context = static_cast<app::Context*>(doc->context());
const ContextReader reader(context);
ContextWriter writer(reader, 500);
ContextWriter writer(reader);
Tx tx(writer.context(), "Reverse Frames");
DocApi api = doc->getApi(tx);
Sprite* sprite = doc->sprite();
Expand Down
12 changes: 6 additions & 6 deletions src/app/ui/color_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void ColorBar::onRemapButtonClick()
// Create remap from m_oldPalette to the current palette
Remap remap(1);
try {
ContextWriter writer(UIContext::instance(), 500);
ContextWriter writer(UIContext::instance());
Sprite* sprite = writer.sprite();
ASSERT(sprite);
if (!sprite)
Expand All @@ -536,7 +536,7 @@ void ColorBar::onRemapButtonClick()
}

try {
ContextWriter writer(UIContext::instance(), 500);
ContextWriter writer(UIContext::instance());
Sprite* sprite = writer.sprite();
if (sprite) {
ASSERT(sprite->pixelFormat() == IMAGE_INDEXED);
Expand Down Expand Up @@ -620,7 +620,7 @@ void ColorBar::setPalette(const doc::Palette* newPalette, const std::string& act
showRemap();

try {
ContextWriter writer(UIContext::instance(), 500);
ContextWriter writer(UIContext::instance());
Sprite* sprite = writer.sprite();
frame_t frame = writer.frame();
if (sprite &&
Expand All @@ -638,7 +638,7 @@ void ColorBar::setPalette(const doc::Palette* newPalette, const std::string& act
void ColorBar::setTransparentIndex(int index)
{
try {
ContextWriter writer(UIContext::instance(), 500);
ContextWriter writer(UIContext::instance());
Sprite* sprite = writer.sprite();
if (sprite &&
sprite->pixelFormat() == IMAGE_INDEXED &&
Expand Down Expand Up @@ -1068,7 +1068,7 @@ void ColorBar::onTimerTick()

// Redraw all editors
try {
ContextWriter writer(UIContext::instance(), 500);
ContextWriter writer(UIContext::instance());
Doc* document(writer.document());
if (document != NULL)
document->notifyGeneralUpdate();
Expand Down Expand Up @@ -1150,7 +1150,7 @@ void ColorBar::updateCurrentSpritePalette(const char* operationName)
if (UIContext::instance()->activeDocument() &&
UIContext::instance()->activeDocument()->sprite()) {
try {
ContextWriter writer(UIContext::instance(), 500);
ContextWriter writer(UIContext::instance());
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
Palette* newPalette = get_current_palette(); // System current pal
Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/editor/moving_cel_state.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -86,7 +87,7 @@ MovingCelState::MovingCelState(Editor* editor,
, m_scaled(false)
, m_handle(handle)
{
ContextWriter writer(m_reader, 500);
ContextWriter writer(m_reader);
Doc* document = editor->document();
ASSERT(!m_celList.empty());

Expand Down
6 changes: 3 additions & 3 deletions src/app/ui/editor/tool_loop_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -505,7 +505,7 @@ class ToolLoopImpl : public ToolLoopBase {
if (getInk()->isPaint()) {
try {
ContextReader reader(m_context, 500);
ContextWriter writer(reader, 500);
ContextWriter writer(reader);
m_expandCelCanvas->commit();
}
catch (const LockedDocException& ex) {
Expand Down Expand Up @@ -535,7 +535,7 @@ class ToolLoopImpl : public ToolLoopBase {
if (m_canceled || !getInk()->isPaint()) {
try {
ContextReader reader(m_context, 500);
ContextWriter writer(reader, 500);
ContextWriter writer(reader);
m_expandCelCanvas->rollback();
}
catch (const LockedDocException& ex) {
Expand Down
3 changes: 2 additions & 1 deletion src/app/util/layer_boundaries.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -96,7 +97,7 @@ void select_layer_boundaries(Layer* layer,
}

try {
ContextWriter writer(UIContext::instance(), 500);
ContextWriter writer(UIContext::instance());
Doc* doc = writer.document();
ASSERT(doc == layer->sprite()->document());

Expand Down

0 comments on commit df74444

Please sign in to comment.