ImageView null pixmap crash fix

This commit is contained in:
2020-10-05 20:45:25 +03:00
parent 3245d71bc8
commit cb86646457

View File

@@ -125,12 +125,15 @@ bool ImageView::eventFilter(QObject * o, QEvent * e) {
void ImageView::adjustView() { void ImageView::adjustView() {
qreal mp = map.width() / map.size().boundedTo(size()).width(); int nw = map.size().boundedTo(size()).width();
if (mp > 1) { if (nw > 0) {
item.setPixmap(map.scaled(map.size()/mp, Qt::KeepAspectRatio, Qt::SmoothTransformation)); qreal mp = map.width() / nw;
} else { if (mp > 1.)
item.setPixmap(map.scaled(map.size() / mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
else
item.setPixmap(map);
} else
item.setPixmap(map); item.setPixmap(map);
}
if (!autofit_) return; if (!autofit_) return;
setSceneRect(item.boundingRect()); setSceneRect(item.boundingRect());
fitInView(&item, Qt::KeepAspectRatio); fitInView(&item, Qt::KeepAspectRatio);