Avoid infinite locking ~ToolLoopImpl()

This situation happens when we have two views for the
same document, and we move the selection in one view,
and then we try to continue the transformation in the
other view.
This commit is contained in:
David Capello 2015-04-09 20:05:02 -03:00
parent c25d9ac272
commit 32bb9c85dc

View File

@ -15,6 +15,7 @@
#include "app/cmd/set_mask.h" #include "app/cmd/set_mask.h"
#include "app/color.h" #include "app/color.h"
#include "app/color_utils.h" #include "app/color_utils.h"
#include "app/console.h"
#include "app/context.h" #include "app/context.h"
#include "app/context_access.h" #include "app/context_access.h"
#include "app/document_undo.h" #include "app/document_undo.h"
@ -190,15 +191,20 @@ public:
if (!m_canceled) { if (!m_canceled) {
// Paint ink // Paint ink
if (getInk()->isPaint()) { if (getInk()->isPaint()) {
retry_commit:; for (int i=0; ; ++i) {
try { // TODO add a "wait_n_seconds" parameter to ContextReader/Writer
ContextReader reader(m_context); try {
ContextWriter writer(reader); ContextReader reader(m_context);
m_expandCelCanvas.commit(); ContextWriter writer(reader);
} m_expandCelCanvas.commit();
catch (const LockedDocumentException&) { break;
base::this_thread::sleep_for(0.25); }
goto retry_commit; catch (const LockedDocumentException& ex) {
if (i == 10)
Console::showException(ex);
else
base::this_thread::sleep_for(0.10);
}
} }
} }
// Selection ink // Selection ink
@ -214,15 +220,19 @@ public:
// If the trace was canceled or it is not a 'paint' ink... // If the trace was canceled or it is not a 'paint' ink...
if (m_canceled || !getInk()->isPaint()) { if (m_canceled || !getInk()->isPaint()) {
retry_rollback:; for (int i=0; ; ++i) {
try { try {
ContextReader reader(m_context); ContextReader reader(m_context);
ContextWriter writer(reader); ContextWriter writer(reader);
m_expandCelCanvas.rollback(); m_expandCelCanvas.rollback();
} break;
catch (const LockedDocumentException&) { }
base::this_thread::sleep_for(0.25); catch (const LockedDocumentException& ex) {
goto retry_rollback; if (i == 10)
Console::showException(ex);
else
base::this_thread::sleep_for(0.10);
}
} }
} }