[Digikam-devel] extragear/graphics/digikam/digikam
Marcel Wiesweg
marcel.wiesweg at gmx.de
Fri Jul 28 22:29:29 BST 2006
SVN commit 567460 by mwiesweg:
Kill the preview ioslave each time properly so that is frees its Shared Memory.
Note: It seems that the usage of Shared Memory is dangerous,
as the segments are not freed when the application crashes.
BUG: 131277
CCMAIL: digikam-devel at kde.org
M +6 -0 imagepreviewjob.cpp
M +19 -5 imagepreviewwidget.cpp
--- trunk/extragear/graphics/digikam/digikam/imagepreviewjob.cpp #567459:567460
@@ -173,6 +173,12 @@
stream >> width >> height >> depth;
preview = QImage(d->shmaddr, width, height, depth,
0, 0, QImage::IgnoreEndian);
+
+ // The buffer supplied to the QImage constructor above must remain valid
+ // throughout the lifetime of the object.
+ // This is not true, the shared memory will be freed or reused.
+ // If we pass the object around, we must do a deep copy.
+ preview = preview.copy();
}
else
{
--- trunk/extragear/graphics/digikam/digikam/imagepreviewwidget.cpp #567459:567460
@@ -91,11 +91,11 @@
ImagePreviewWidget::~ImagePreviewWidget()
{
- if (!d->previewJob.isNull())
+ if (d->previewJob)
d->previewJob->kill();
-
+
d->blinkPreviewTimer->stop();
-
+
delete d;
}
@@ -107,6 +107,9 @@
d->previewBlink = false;
d->blinkPreviewTimer->start(200);
+ if (d->previewJob)
+ d->previewJob->kill();
+
d->previewJob = new ImagePreviewJob(KURL(path), 1024, AlbumSettings::instance()->getExifRotate());
connect(d->previewJob, SIGNAL(signalImagePreview(const KURL&, const QImage&)),
@@ -129,9 +132,16 @@
void ImagePreviewWidget::slotGotImagePreview(const KURL&, const QImage& preview)
{
d->blinkPreviewTimer->stop();
- d->previewJob = 0;
d->preview = preview;
d->pixmap = QPixmap(contentsRect().size());
+
+ // It is very important to kill the thumbnail job properly
+ // so that is frees its shared memory. Otherwise the memory
+ // will _never_ be freed, see b.k.o. #131277
+ if (d->previewJob)
+ d->previewJob->kill();
+ d->previewJob = 0;
+
updatePixmap();
repaint(false);
emit previewComplete();
@@ -140,7 +150,11 @@
void ImagePreviewWidget::slotFailedImagePreview(const KURL&)
{
d->blinkPreviewTimer->stop();
- d->previewJob = 0;
+
+ if (d->previewJob)
+ d->previewJob->kill();
+ d->previewJob = 0;
+
d->preview = QImage();
d->pixmap = QPixmap(contentsRect().size());
updatePixmap();
More information about the Digikam-devel
mailing list