Fixed a bug in indicator button panel which caused infinity loop in paint event
[situare] / src / ui / indicatorbuttonpanel.cpp
index a34369e..d3a921f 100644 (file)
@@ -192,8 +192,6 @@ void IndicatorButtonPanel::paintEvent(QPaintEvent *event)
                                  , EXTRA_SPACE_BOTTOM);
         backgroundPath.addRoundedRect(distanceLabelRect, RADIUS_WIDTH, RADIUS_HEIGHT);
         painter.fillPath(backgroundPath, QBrush(*m_normalColor));
-
-        update();
     }
 
     if(m_isDraggable) {
@@ -265,8 +263,12 @@ void IndicatorButtonPanel::setDraggable(bool mode, QPoint eventPosition)
 
 void IndicatorButtonPanel::setIndicatorButtonEnabled(bool enabled)
 {
-        m_indicatorButton->setChecked(enabled);
-        m_distanceTextLabel->setVisible(!enabled);
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_indicatorButton->setChecked(enabled);
+    m_distanceTextLabel->setVisible(!enabled);
+
+    update();
 }
 
 void IndicatorButtonPanel::timerExpired()
@@ -300,16 +302,16 @@ void IndicatorButtonPanel::updateValues(qreal direction, qreal distance, bool dr
     }
     else if(m_distance < MAX_TO_METERS)
     {
-        m_distanceText.setNum(m_distance, 0 , 0);
+        m_distanceText.setNum(m_distance, 'f', 0);
         m_distanceText.append(UNIT_METER);
     }
     else if(m_distance < MAX_TO_KM_WITH_DESIMAL)
     {
-        m_distanceText.setNum(m_distance / M_TO_KM, 1, 1);
+        m_distanceText.setNum(m_distance / M_TO_KM, 'f', 1);
         m_distanceText.append(UNIT_KILOMETER);
     }
     else {
-        m_distanceText.setNum(m_distance / M_TO_KM, 0, 0);
+        m_distanceText.setNum(m_distance / M_TO_KM, 'f', 0);
         m_distanceText.append(UNIT_KILOMETER);
     }