Undoing after saving as

Bart Coppens kde at bartcoppens.be
Tue Jun 28 16:26:08 CEST 2005


> My guess is that this undo information is created by the export, when
> export flattens the image. I could be totally wrong, though.
So I did some more research on this, and come to the following: when I open a 
test pic in krita, and close it immediately, the tile manager reports no 
leftover tiles in memory:
krita: 0 out of 0 bytes in memory
krita: 0 out of 0 tiles in memory

Loading that file, saving it to Krita Native File Format and exiting gives the 
same info. However, loading, and _exporting_ it to png gives me
krita: TileManager: at exit information:
krita: 7766016 out of 12091392 bytes in memory
krita: 474 out of 738 tiles in memory

Which is a lot more than the 0 of doing nothing. According to the tile 
manager, all these tiles are created in the usage of

11: /usr/lib/libkritacommon.so.1
(_ZN21KisPaintDeviceVisitorclER10KisPainterR18KisSharedPtrVectorI8KisLayerE+0x26) 
[0x41caed
c6]
12: /usr/lib/libkritacommon.so.1(_ZN8KisImage7flattenEv+0x1ca) [0x41caa85c]
13: /usr/lib/kde3/libkritamagickexport.so(_ZN12MagickExport7convertERK8QCStringS2_+0x2f5) 
[0x446cc8ab]


Also, after saving, the 'undo flatten image' action is suddenly added to the 
krita undo list after exporting (before that, there  was  no undo information 
at all).  Undoing it leads to the reported crash.

And now for the really weird part. I tried disabling storing undo information 
explicitly in the export filter like this:
Index: filters/krita/magick/magickexport.cpp
===================================================================
--- filters/krita/magick/magickexport.cpp       (revision 429649)
+++ filters/krita/magick/magickexport.cpp       (working copy)
@@ -63,6 +63,8 @@
        KisImage * img = new KisImage(*output->currentImage());
        Q_CHECK_PTR(img);

+       output->undoAdapter()->setUndo(false);
+
        KisImageMagickConverter ib(output, output->undoAdapter());

        img->flatten();

Now it crashes _during_ export:

Program received signal SIGSEGV, Segmentation fault.
0x400859d0 in KShared::_KShared_ref() const (this=0x41) at ksharedptr.h:61
61         void _KShared_ref() const { count++; }
(gdb) bt
#0  0x400859d0 in KShared::_KShared_ref() const (this=0x41) at ksharedptr.h:61
#1  0x41cad2fe in KSharedPtr<KisLayer>::operator=(KSharedPtr<KisLayer> const&) 
(this=0x451ca010, p=@0x81d19fc)
    at ksharedptr.h:132
#2  0x41cae5cf in qCopy<KSharedPtr<KisLayer>*, KSharedPtr<KisLayer>*> 
(_begin=0x81d1a00, _end=0x8305380, _dest=0x451ca014)
    at qtl.h:76
#3  0x41cae845 in QValueVectorPrivate (this=0x8f54228, x=@0x81e3490) at 
qvaluevector.h:130
#4  0x41cae44f in QValueVector<KSharedPtr<KisLayer> >::detachInternal() 
(this=0x990efa8) at qvaluevector.h:499
#5  0x41cadeeb in QValueVector<KSharedPtr<KisLayer> >::detach() 
(this=0x990efa8) at qvaluevector.h:479
#6  0x41cad667 in QValueVector<KSharedPtr<KisLayer> >::operator[](unsigned) 
(this=0x990efa8, i=0) at qvaluevector.h:357
#7  0x41ca9a3d in KisImage::layer(unsigned) (this=0x990ef00, npos=0) 
at ../../../krita/core/kis_image.cc:931
#8  0x446cc8e7 in MagickExport::convert(QCString const&, QCString const&) 
(this=0x8ec4120, from=@0x9837108, to=@0x9837110)
    at ../../../../filters/krita/magick/magickexport.cpp:72
......

Notice the obviously invalid pointers at the top of the backtrace. Now 
whatever would be the cause of this, disabling undo should not lead to 
crashes. Unfortunately, I can't seem to find the cause of this at all :-/ 
Maybe someone else has an idea?

Bart Coppens


More information about the kimageshop mailing list