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

List:       kde-commits
Subject:    koffice/krita/image
From:       Dmitry Kazakov <dimula73 () gmail ! com>
Date:       2010-11-04 12:53:46
Message-ID: 20101104125346.77117AC89B () svn ! kde ! org
[Download RAW message or body]

SVN commit 1193067 by dkazakov:

Fixed a crash due to calls to projection->set{X,Y}()

We can't adjust projection's offset on every call to
KisSafeProjection::getDeviceLazy() because other threads may *write*
to this device at the same time. So we adjust its shift only once,
that is on projection's initialization.

BUG:255617


 M  +0 -7      kis_layer.cc  
 M  +30 -0     tests/kis_layer_test.cpp  
 M  +1 -1      tests/kis_layer_test.h  


--- trunk/koffice/krita/image/kis_layer.cc #1193066:1193067
@@ -48,10 +48,6 @@
 
 class KisSafeProjection {
 public:
-    KisPaintDeviceSP getDevice() {
-        return m_projection;
-    }
-
     KisPaintDeviceSP getDeviceLazy(KisPaintDeviceSP prototype) {
         QMutexLocker locker(&m_lock);
 
@@ -64,9 +60,6 @@
             m_projection->makeCloneFromRough(prototype, prototype->extent());
         }
 
-        m_projection->setX(prototype->x());
-        m_projection->setY(prototype->y());
-
         return m_projection;
     }
 
--- trunk/koffice/krita/image/tests/kis_layer_test.cpp #1193066:1193067
@@ -27,6 +27,7 @@
 #include <KoColorSpaceRegistry.h>
 
 #include "kis_paint_device.h"
+#include "kis_selection.h"
 #include "kis_filter_mask.h"
 #include "kis_transparency_mask.h"
 
@@ -292,7 +293,36 @@
 
 }
 
+void KisLayerTest::testMoveLayerWithMaskThreaded()
+{
+    /**
+     * This test ensures that the layer's original() can be moved
+     * while its projection is still being updated
+     */
 
+    const KoColorSpace * colorSpace = KoColorSpaceRegistry::instance()->rgb8();
+    KisImageSP image = new KisImage(0, 2000, 2000, colorSpace, "walker test");
+
+    KisLayerSP paintLayer = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8);
+    image->addNode(paintLayer, image->rootLayer());
+
+    paintLayer->paintDevice()->fill(image->bounds(), KoColor(Qt::black, colorSpace));
+
+    KisTransparencyMaskSP transpMask = new KisTransparencyMask();
+    transpMask->initSelection(0, paintLayer);
+    image->addNode(transpMask, paintLayer);
+
+    for(int i = 0; i < 500; i++) {
+        paintLayer->setDirty();
+
+        QTest::qSleep(1 + (qrand() & 63));
+
+        paintLayer->setX((i*67) % 1873);
+        paintLayer->setY((i*23) % 1873);
+    }
+}
+
+
 QTEST_KDEMAIN(KisLayerTest, NoGUI)
 #include "kis_layer_test.moc"
 
--- trunk/koffice/krita/image/tests/kis_layer_test.h #1193066:1193067
@@ -105,7 +105,7 @@
     void testMoveLayer();
     void testHasEffectMasks();
     void testMasksChangeRect();
-
+    void testMoveLayerWithMaskThreaded();
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

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