Do not create label if string is empty.

Do not create a text label if the returned string is empty.
Also, fixed a potential crash after not creating a label and adding it to
the list of created labels.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-01-27 16:21:13 -02:00 committed by Dirk Hohndel
parent fcc17c717d
commit 7a07665d89

View file

@ -121,12 +121,15 @@ void DiveCartesianAxis::updateTicks()
DiveTextItem *label = NULL;
if (showText){
QString text = textForValue(currValue);
if(text.isEmpty())
continue; // Do not create or do anything with an empty string.
label = new DiveTextItem(this);
label->setText(textForValue(currValue));
label->setBrush(QBrush(textColor));
label->setBrush(colorForValue(currValue));
labels.push_back(label);
}
labels.push_back(label);
if (orientation == RightToLeft || orientation == LeftToRight) {
if(showText){
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);