ImageView null pixmap crash fix
This commit is contained in:
@@ -125,12 +125,15 @@ bool ImageView::eventFilter(QObject * o, QEvent * e) {
|
||||
|
||||
|
||||
void ImageView::adjustView() {
|
||||
qreal mp = map.width() / map.size().boundedTo(size()).width();
|
||||
if (mp > 1) {
|
||||
item.setPixmap(map.scaled(map.size()/mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
} else {
|
||||
int nw = map.size().boundedTo(size()).width();
|
||||
if (nw > 0) {
|
||||
qreal mp = map.width() / nw;
|
||||
if (mp > 1.)
|
||||
item.setPixmap(map.scaled(map.size() / mp, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
else
|
||||
item.setPixmap(map);
|
||||
} else
|
||||
item.setPixmap(map);
|
||||
}
|
||||
if (!autofit_) return;
|
||||
setSceneRect(item.boundingRect());
|
||||
fitInView(&item, Qt::KeepAspectRatio);
|
||||
|
||||
Reference in New Issue
Block a user