From a78f75054ace488bc4b0748a10c50c0b7734e592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=B6fferlein?= Date: Thu, 6 Sep 2018 23:49:17 +0200 Subject: [PATCH] Bugfix in the annotation area The annotation ID was taken from an object already deleted - on MSVC this becomes an issue. --- src/ant/ant/antService.cc | 11 +++++++---- testdata/ruby/antTest.rb | 5 ++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index 6d8b27959..60161e266 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -921,7 +921,8 @@ Service::insert_ruler (const ant::Object &ruler, bool limit_number) // create the ruler from the template ant::Object *new_ruler = new ant::Object (ruler); - new_ruler->id (idmax + 1); + int new_id = idmax + 1; + new_ruler->id (new_id); mp_view->annotation_shapes ().insert (db::DUserObject (new_ruler)); // delete surplus rulers @@ -929,7 +930,7 @@ Service::insert_ruler (const ant::Object &ruler, bool limit_number) reduce_rulers (m_max_number_of_rulers); } - return new_ruler->id (); + return new_id; } /** @@ -2082,10 +2083,12 @@ Service::change_ruler (obj_iterator pos, const ant::Object &to) ant::Object *new_ruler = new ant::Object (to); const ant::Object *current_ruler = dynamic_cast (pos->ptr ()); tl_assert (current_ruler != 0); - new_ruler->id (current_ruler->id ()); + + int new_id = current_ruler->id (); + new_ruler->id (new_id); mp_view->annotation_shapes ().replace (pos, db::DUserObject (new_ruler)); - annotation_changed_event (new_ruler->id ()); + annotation_changed_event (new_id); // and make selection "visible" selection_to_view (); diff --git a/testdata/ruby/antTest.rb b/testdata/ruby/antTest.rb index 17b8dd21a..71367969e 100644 --- a/testdata/ruby/antTest.rb +++ b/testdata/ruby/antTest.rb @@ -72,7 +72,7 @@ class RBA::Annotation "diag_yx" elsif s == OutlineBox "diag_box" - else + else "" end end @@ -401,7 +401,7 @@ class Ant_TestClass < TestBase lv = mw.current_view aac = 0 - ac = [] + ac = [] asc = 0 lv.on_annotations_changed { aac += 1 } lv.on_annotation_changed { |id| ac << id } @@ -533,4 +533,3 @@ class Ant_TestClass < TestBase end load("test_epilogue.rb") -