Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KLayout 0.28.2 crashes when registering a plugin if a layout exists #1242

Closed
caspar-iqm opened this issue Jan 2, 2023 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@caspar-iqm
Copy link

The following Python code defines a simple dummy plugin, creates a new layout, and then registers the plugin. Running it crashes the KLayout application since 0.28 (tested to crash on 0.28.2, verified that this worked on the last version of 0.27).

import pya

class DummyPlugin(pya.Plugin):
    def __init__(self, manager, view):
        self.manager = manager
        self.view = view


class DummyPluginFactory(pya.PluginFactory):
    def __init__(self):
        self.register(1000, "dummy_plugin", "Dummy Plugin")
        
    def create_plugin(self, manager, _, view):
        return DummyPlugin(manager, view)


# Create a new layout
main_window = pya.MainWindow.instance()
main_window.create_layout(2)

# Register plugin
DummyPluginFactory()

Reversing the order, i.e. calling DummyPluginFactory() before main_window.create_layout(2), works fine.

So there is a workaround, just make sure the plugins are registered before any layouts are created. Since this is a hard crash and new behavior in 0.28 I still report it as bug.

@klayoutmatthias klayoutmatthias self-assigned this Jan 3, 2023
@klayoutmatthias klayoutmatthias added this to the 0.28.3 milestone Jan 3, 2023
@klayoutmatthias
Copy link
Collaborator

Thanks for these creative border cases :)

I will try to debug and fix it.

Matthias

klayoutmatthias added a commit that referenced this issue Jan 4, 2023
…f a layout exists)

Problem was twofold: first, events are triggered during
construction of the plugin which met an uninitialized
pointer. Second, the clearing of existing plugins failed
because of iterating a vector while destroying it's members
erased member of it.
@klayoutmatthias
Copy link
Collaborator

Problem is found and a fix will be released with 0.28.3.

Thanks again for reporting this problem.

Matthias

@caspar-iqm
Copy link
Author

Thanks a lot!

klayoutmatthias added a commit that referenced this issue Jan 11, 2023
Fixed issue #1242 (KLayout 0.28.2 crashes when registering a plugin i…
@klayoutmatthias
Copy link
Collaborator

Should be fixed with 0.28.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants