1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-19 04:02:09 +01:00

Added missing image validity check

(invalid images cause a divide-by-zero error later in the code)
This commit is contained in:
Martin Tůma 2021-12-06 22:58:49 +01:00
parent 428fb934c4
commit 308ca9c702

View File

@ -40,7 +40,7 @@ void TextPointItem::setPos(const QPoint &point, bool padding)
QPainterPath shape; QPainterPath shape;
QRect iconRect; QRect iconRect;
if (_img) { if (_img && !_img->isNull()) {
QSize s(_img->size() / _img->devicePixelRatioF()); QSize s(_img->size() / _img->devicePixelRatioF());
int xOffset = padding ? s.width() : s.width() / 2; int xOffset = padding ? s.width() : s.width() / 2;
iconRect = QRect(QPoint(point.x() - xOffset, point.y() iconRect = QRect(QPoint(point.x() - xOffset, point.y()
@ -57,7 +57,7 @@ void TextPointItem::setPos(const QPoint &point, bool padding)
void TextPointItem::paint(QPainter *painter) const void TextPointItem::paint(QPainter *painter) const
{ {
if (_img) { if (_img && !_img->isNull()) {
QSize s(_img->size() / _img->devicePixelRatioF()); QSize s(_img->size() / _img->devicePixelRatioF());
painter->drawImage(QPoint(_rect.left(), _rect.center().y() painter->drawImage(QPoint(_rect.left(), _rect.center().y()
- s.height()/2), *_img); - s.height()/2), *_img);