Replaced duplicated code with Trace::get_y
[pulseview.git] / pv / view / trace.cpp
index e825337c6d4156fb4e430cfface2a5aab2d0cb08..1231eae4830b61ccc0429566963408e5bcbd175a 100644 (file)
@@ -109,8 +109,7 @@ void Trace::paint_fore(QPainter &p, int left, int right)
 
 void Trace::paint_label(QPainter &p, int right, bool hover)
 {
-       assert(_view);
-       const int y = _v_offset - _view->v_offset();
+       const int y = get_y();
 
        p.setBrush(_colour);
 
@@ -187,6 +186,7 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent)
 
 int Trace::get_y() const
 {
+       assert(_view);
        return _v_offset - _view->v_offset();
 }
 
@@ -194,8 +194,6 @@ QRectF Trace::label_rect(int right)
 {
        using pv::view::View;
 
-       assert(_view);
-
        QFontMetrics m(QApplication::font());
        const QSize text_size(
                m.boundingRect(QRect(), 0, _name).width(),