[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    [Calligra] 1081b47 Added a workaround for bug 255617
From:       Dmitry Kazakov <dimula73 () gmail ! com>
Date:       2010-12-19 13:01:45
Message-ID: 20101219130145.C3C8DA6090 () git ! kde ! org
[Download RAW message or body]

commit 1081b47359851f53d4a73eca2ecf3b8b938c2cb1
branch master
Author: Dmitry Kazakov <dimula73@gmail.com>
Date:   Sun Dec 19 15:52:44 2010 +0300

    Added a workaround for bug 255617
    
    1st: see a commit 1f3e41ed10baeb939c017b315d6b5986aed09d0b
    
    This patch makes KisToolMove block the updates for the image while it
    sets the offset for the layer. This is just a workaround, iterators
    infrastructure must be revised to conform always-read idea.
    
    This patch should be backported to 2.3
    
    CCMAIL:kimageshop@kde.org
    CCBUG:255617

diff --git a/krita/image/commands/kis_node_move_command.cpp \
b/krita/image/commands/kis_node_move_command.cpp index 571d404..40bdef4 100644
--- a/krita/image/commands/kis_node_move_command.cpp
+++ b/krita/image/commands/kis_node_move_command.cpp
@@ -55,8 +55,16 @@ void KisNodeMoveCommand::undo()
 
 void KisNodeMoveCommand::moveTo(const QPoint& pos)
 {
+    /**
+     * FIXME: Hack alert:
+     * Our iterators don't have guarantees on thread-safety
+     * when the offset varies. When it is fixed, remove the locking.
+     * see: KisIterator::stressTest(), KisToolMove::mousePressEvent()
+     */
+    m_image->lock();
     m_node->setX(pos.x());
     m_node->setY(pos.y());
+    m_image->unlock();
 
     m_node->setDirty(m_updateRect);
     
diff --git a/krita/plugins/tools/defaulttools/kis_tool_move.cc \
b/krita/plugins/tools/defaulttools/kis_tool_move.cc index 8068c4f..2ba2447 100644
--- a/krita/plugins/tools/defaulttools/kis_tool_move.cc
+++ b/krita/plugins/tools/defaulttools/kis_tool_move.cc
@@ -157,7 +157,7 @@ void KisToolMove::mousePressEvent(KoPointerEvent *event)
             node = currentNode();
         }
 
-        currentImage()->undoAdapter()->beginMacro(i18n("Move"));
+        image->undoAdapter()->beginMacro(i18n("Move"));
 
         if (selection && !selection->isTotallyUnselected(image->bounds()) && \
                !selection->isDeselected() && !node->inherits("KisSelectionMask")) {
             // Create a temporary layer with the contents of the selection of the \
current layer. @@ -187,7 +187,7 @@ void KisToolMove::mousePressEvent(KoPointerEvent \
*event)  
                     if (image->globalSelection()) {
                         KisDeselectGlobalSelectionCommand* cmd = new \
                KisDeselectGlobalSelectionCommand(image);
-                        currentImage()->undoAdapter()->addCommand(cmd);
+                        image->undoAdapter()->addCommand(cmd);
                     }
                 }
 
@@ -198,11 +198,11 @@ void KisToolMove::mousePressEvent(KoPointerEvent *event)
                 }
 
                 // create the new layer and add it.
-                KisPaintLayerSP layer = new KisPaintLayer(currentImage(),
+                KisPaintLayerSP layer = new KisPaintLayer(image,
                         node->name() + "(moved)",
                         oldLayer->opacity(),
                         dev);
-                currentImage()->undoAdapter()->addCommand(new \
KisImageLayerAddCommand(currentImage(), layer, node->parent(), node)); +              \
image->undoAdapter()->addCommand(new KisImageLayerAddCommand(image, layer, \
node->parent(), node));  view->nodeManager()->activateNode(layer);
                 m_targetLayer = node;
                 m_selectedNode = layer;
@@ -213,8 +213,17 @@ void KisToolMove::mousePressEvent(KoPointerEvent *event)
             m_targetLayer = 0;
         }
 
+        /**
+         * FIXME: Hack alert:
+         * Our iterators don't have guarantees on thread-safety
+         * when the offset varies. When it is fixed, remove the locking
+         * see: KisIterator::stressTest()
+         */
+        image->lock();
         m_layerStart.setX(node->x());
         m_layerStart.setY(node->y());
+        image->unlock();
+
         m_layerPosition = m_layerStart;
         m_dragStart = pos.toPoint();
     }
@@ -273,14 +282,19 @@ void KisToolMove::drag(const QPoint& original)
 
         pos -= m_dragStart; // convert to delta
         rc = m_selectedNode->extent();
+
+        // FIXME: see comment in KisToolMove::mousePressEvent()
+        KisImageWSP image = currentImage();
+        image->lock();
         m_selectedNode->setX(m_selectedNode->x() + pos.x());
         m_selectedNode->setY(m_selectedNode->y() + pos.y());
+        image->unlock();
 
         rc = rc.unite(m_selectedNode->extent());
 
         m_layerPosition = QPoint(m_selectedNode->x(), m_selectedNode->y());
         m_dragStart = original;
-        
+
         if (m_selectedNode->inherits("KisSelectionMask")) {
             currentImage()->undoAdapter()->emitSelectionChanged();
         }
_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic