Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[editor widgets] Avoid infinite image resize loop
  • Loading branch information
nirvn authored and nyalldawson committed May 17, 2021
1 parent fa8f7aa commit 209afdc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gui/qgspixmaplabel.cpp
Expand Up @@ -32,8 +32,7 @@ void QgsPixmapLabel::setPixmap( const QPixmap &p )
updateGeometry();
}

QLabel::setPixmap( mPixmap.scaled( this->size(),
Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}

int QgsPixmapLabel::heightForWidth( int width ) const
Expand All @@ -58,7 +57,8 @@ void QgsPixmapLabel::resizeEvent( QResizeEvent *e )
QLabel::resizeEvent( e );
if ( !mPixmap.isNull() )
{
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
// Avoid infinite resize loop by setting a pixmap that'll always have a width and height less or equal to the label size
QLabel::setPixmap( mPixmap.scaled( this->size() -= QSize( 1, 1 ), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}
}

Expand Down

0 comments on commit 209afdc

Please sign in to comment.