Commit 6cc5a511 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

Fix segfault/call on invalid pointer

We didn't set the AbstractImageView in AbstractImageViewPrivate early
enough, and createAlphaBackgroundTexture() tried to call stuff on q.

Quote from asan:

==161679==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fa8cdcc193a bp 0x7ffe601e4a00 sp 0x7ffe601e48f0 T0)
==161679==The signal is caused by a READ memory access.
==161679==Hint: address points to the zero page.
    #0 0x7fa8cdcc1939 in Gwenview::AbstractImageViewPrivate::createAlphaBackgroundTexture() (gwenview/build/bin/
    #1 0x7fa8cdcc28b8 in Gwenview::AbstractImageViewPrivate::AbstractImageViewPrivate() (gwenview/build/bin/
    #2 0x7fa8cdca46a2 in Gwenview::AbstractImageView::AbstractImageView(QGraphicsItem*) ../lib/documentview/abstractimageview.cpp:145
    #3 0x7fa8cdd500a5 in Gwenview::RasterImageView::RasterImageView(QGraphicsItem*) ../lib/documentview/rasterimageview.cpp:194

Reviewed By: ngraham

Differential Revision:
parent 0d36aa4a
......@@ -60,7 +60,7 @@ struct AbstractImageViewPrivate
QPointF mLastDragPos;
QSizeF mDocumentSize;
const QPixmap mAlphaBackgroundTexture = createAlphaBackgroundTexture();
const QPixmap mAlphaBackgroundTexture;
void adjustImageOffset(Verbosity verbosity = Notify)
......@@ -128,6 +128,11 @@ struct AbstractImageViewPrivate
return pix;
AbstractImageViewPrivate(AbstractImageView *parent) :
{ }
void checkAndRequestZoomAction(const QGraphicsSceneMouseEvent* event)
if (event->modifiers() & Qt::ControlModifier) {
......@@ -142,9 +147,8 @@ struct AbstractImageViewPrivate
AbstractImageView::AbstractImageView(QGraphicsItem* parent)
: QGraphicsWidget(parent)
, d(new AbstractImageViewPrivate)
, d(new AbstractImageViewPrivate(this))
d->q = this;
d->mControlKeyIsDown = false;
d->mEnlargeSmallerImages = false;
d->mZoom = 1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment