View: Store CursorPair in a shared_ptr
[pulseview.git] / pv / view / cursor.cpp
index 6a4733112fbb6882edf3d281aed570cd5f19f538..836d0e93d758fd911e371ef5383eda291ffa41c6 100644 (file)
@@ -45,6 +45,11 @@ Cursor::Cursor(View &view, double time) :
 {
 }
 
+bool Cursor::enabled() const
+{
+       return view_.cursors_shown();
+}
+
 QString Cursor::get_text() const
 {
        return pv::util::format_time(time_, view_.tick_prefix(), 2);
@@ -76,9 +81,10 @@ QRectF Cursor::get_label_rect(const QRect &rect) const
 
 shared_ptr<Cursor> Cursor::get_other_cursor() const
 {
-       const CursorPair &cursors = view_.cursors();
-       return (cursors.first().get() == this) ?
-               cursors.second() : cursors.first();
+       const shared_ptr<CursorPair> cursors(view_.cursors());
+       assert(cursors);
+       return (cursors->first().get() == this) ?
+               cursors->second() : cursors->first();
 }
 
 } // namespace view