[Bug?] 'bookmark_view' does not exist anymore in ruby in klayout 28.6

edited April 2023 in KLayout Development

Hi,
I have tested version 28.6 comming from 27.13; I get "undefind method 'bookmark_view' for RBA::LayoutViewBase: (Class NoMethodeError)" which was not the case in 27.13 and before.
Additional question: Is there any chance to have a command to delete a bookmark in the next versions?
Best regards
Frank

Comments

  • edited April 2023

    Could you paste some code? This method was not deleted.

    This works for me:

    pya.LayoutView.current().bookmark_view("bookmarked")
    

    And yes, changes for getting a new function in the API are not zero.

    But you know, the problem basically is this:

  • edited April 2023

    Hallo Matthias,
    thank you for your fast answer. I know klayout is a one-man project, which is unbelievable when you look at the size and quality of the project.
    Your example was in python, I use the ruby binding.
    The commands

        lv=Application::instance.main_window.current_view
        lv.bookmark_view('test') 
    

    work fine in 27.13, but bring "undefind method 'bookmark_view' for RBA::LayoutViewBase: (Class NoMethodeError)" in 28.7 under Windows. (I use only the windows version.)
    Best regards,
    Frank

  • That's weird. I just tried on Windows 10, Version 0.28.7, 64bit. The above code works for me ...

    Are you using 64bit?

    I entered the code in the console of the macro IDE. What puzzles me is that you see "LayoutViewBase" which is actually a special class not visible in the normal application. It is true that this class does not implement "bookmark_view", but "LayoutView" - which is the actual UI-based view - does. This separation has been introduced with the provisioning of headless layout views.

    In my case - from the console - Application::instance.main_window.current_view gives me a "LayoutView" object and "bookmark_view" works.

    What is going on?

    Matthias

  • edited May 2023

    Hallo Matthias,
    thank you for your fast answer.
    I found on my Windows 10; Version 0.28.7, 64bit:
    In a fresh installed Klayout without any other user macros the macro

    module MyMacro
      include RBA
      lv=Application::instance.main_window.current_view
      lv.bookmark_view('test2')
    end
    

    runs fine.

    However if I use a custom plugin via a autostart macro
    (I reduced my real plugin as much as possible to demonstrate the problem.)

    module MpluginEC
    
    include RBA
    
    class PluginECFactory < PluginFactory
      def initialize
        register(100000, "plugin_extern", "External\nControl")
      end
      def create_plugin(manager, root, view)
        return PluginEC.new
      end
    end
    
    class PluginEC < Plugin
      def mouse_moved_event(p, buttons, prio)
        if prio
          # Set the cursor to cross if our plugin is active.
          set_cursor(RBA::Cursor::Cross)
        end
        # Returning false indicates that we don't want to consume the event.
        false
      end
    end
    
    PluginECFactory.new
    
    end
    

    I get the Error when I then try to run the first macro.
    The macros were under C:\Users\~-user-~\KLayout\macros
    (No problems in 0.27.13. and before)
    Best regards
    Frank

  • @Frank Many thanks for that analysis and the test case. I was able to reproduce the problem.

    In 0.28, LayoutViewBase was introduced which does not offer the bookmark view function, but the derived class LayoutView does.

    For some reason, the plugin registration prevents this object from being promoted to LayoutView - probably as a consequence of early C++/Ruby object binding. I have created a ticket for this: https://github.com/KLayout/klayout/issues/1360.

    Unfortunately I have not found a workaround for the problem quickly. The object binding is pretty persistent, so it's hard to revert it without destroying the view.

    Matthias

Sign In or Register to comment.