Clear all markers from current view

edited December 2013 in Ruby Scripting
Hi Matthias-

I have a bitmapper code that calculates the exact location of certain bit in a memory array, then it puts a marker on this bit.
After placing many of these markers I would like to clean the view from these markers.

What is the best method to do that?

Thanks, Mikamar

Comments

  • edited November -1

    Hi,

    A marker es removed from the view when the RBA::Marker object is destroyed. Because that is automatically done by the garbage collector, you'll have to keep a marker reference somewhere in your code. You can force a marker to be destroyed by using the "destroy" method of the marker.

    Typically code to create markers looks like this:

    class MyApp
    
      def create_markers(layout_view)
        @markers = []
        ... create and configure a marker: ...
        marker = RBA::Marker::new(layout_view)
        marker.color = ...
        marker.set_box(...)
        @markers << marker   # save a reference
        ...
      end
    
      def remove_markers
        # explicitly destroy the markers (don't wait for that to happen in the GC)
        @markers.each do |m|
          m.destroy
        end
        @markers = nil
      end
    
    end
    

    This code employs a class to wrap all the code of the application. The actual implementation does not matter - the important point is to keep references to the marker objects to protect then from being destroyed by the GC as long as you need them and to explicitly destroy them when the are no longer required.

    Matthias

  • edited November -1
    Thanks!
Sign In or Register to comment.