Fix QPixmap::scaled: Pixmap is a null pixmap error

This commit is contained in:
2016-07-30 21:28:14 +02:00
parent 59970e20de
commit 32e06a3e08
+2 -2
View File
@@ -32,7 +32,7 @@ void ImageScrollArea::setImage(const QPixmap &img)
void ImageScrollArea::setScale(float scale) void ImageScrollArea::setScale(float scale)
{ {
if(scale > 4 || (scale < 0.2 && scale > 0)) if(scale > 4 || (scale < 0.2 && scale > 0) || m_pixmap.isNull())
return; return;
m_scale = scale; m_scale = scale;
@@ -92,7 +92,7 @@ void ImageScrollArea::mousePressEvent(QMouseEvent *event)
void ImageScrollArea::resizeEvent(QResizeEvent *event) void ImageScrollArea::resizeEvent(QResizeEvent *event)
{ {
if(m_scale < 0) if(m_scale < 0 && !m_pixmap.isNull())
{ {
m_label->setPixmap(m_pixmap.scaled(event->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); m_label->setPixmap(m_pixmap.scaled(event->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
m_label->resize(event->size()); m_label->resize(event->size());