From c2140216184999eeb26663a4176dd4805e410e70 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 Dec 2019 21:51:10 +0100 Subject: [PATCH] Fixed #440 (issue with LayoutView#each_annotation_selected) --- src/ant/ant/gsiDeclAnt.cc | 4 ++-- testdata/ruby/antTest.rb | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index 68cb6f6c1..367183222 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -1063,7 +1063,7 @@ public: typedef AnnotationRef value_type; typedef std::map::const_iterator iterator_type; typedef void pointer; - typedef const value_type &reference; + typedef value_type reference; typedef std::forward_iterator_tag iterator_category; typedef void difference_type; @@ -1088,7 +1088,7 @@ public: return *this; } - value_type operator* () const + reference operator* () const { return value_type (*(static_cast (m_iter->first->ptr ())), m_services[m_service]->view ()); } diff --git a/testdata/ruby/antTest.rb b/testdata/ruby/antTest.rb index 9b7eaa6d7..27e2a34f1 100644 --- a/testdata/ruby/antTest.rb +++ b/testdata/ruby/antTest.rb @@ -530,6 +530,40 @@ class Ant_TestClass < TestBase end + # each_annotation_selected + def test_4 + + if !RBA.constants.member?(:Application) + return + end + + mw = RBA::Application::instance.main_window + mw.close_all + mw.create_layout( 0 ) + lv = mw.current_view + + a = annot_obj( RBA::DPoint::new( 1.0, 2.0 ), RBA::DPoint::new( 3.0, 4.0 ), "a", "b", "c", 1, 2, false, 3 ) + assert_equal( a.is_valid?, false ) + lv.insert_annotation( a ) + + mw.cm_select_all + + arr = [] + lv.each_annotation_selected { |a| arr.push(a) } + assert_equal(arr.size, 1) + assert_equal(arr[0].to_s, "p1=1,2, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal") + + arr[0].p1 = RBA::DPoint::new(11, 12) + + arr = [] + lv.each_annotation_selected { |a| arr.push(a) } + assert_equal(arr.size, 1) + assert_equal(arr[0].to_s, "p1=11,12, p2=3,4, fmt=a, fmt_x=b, fmt_y=c, style=arrow_end, outline=diag_xy, snap=false, ac=horizontal") + + mw.close_all + + end + end load("test_epilogue.rb")