Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Segfault when calling LayoutView() in Python script

Hi,

I am trying to save an image with LayoutView.save_image()
But merely creating a new LayoutView object results in a segmentation fault (ERROR: Signal number: 11).

I use Klayout 0.25.9 (installed with the deb file from https://www.klayout.de/build.html) in a fully updated Ubuntu 18.04 LTS VM to call the Python script in interpreter mode:

klayout -z -nc -r /path/to/test_layoutview.py

test_layoutview.py:

import pya

#Test if calling LayoutView() works
lv = pya.LayoutView()  #This causes the seg fault

I have uploaded the full error message and the log of valgrind from running valgrind klayout -z -nc -r /path/to/test_layoutview.py .. >valgrind.log 2>&1 to Github.
Issue #289 is on Github already, but I thought discussing it in the forum as well might be a good idea.
It may of course be an error on my part. If so, I would be thankful for advice on saving a PNG image with a Python script other than:

import pya
layout = pya.Layout()
layout.read('filename.gds')
lv = pya.LayoutView()
lv.create_layout(lv, True)
lv.save_image('filename.png', 500, 500)

Any help would be highly appreciated :-)

SegfaultErrorMessage.txt
valgrind.log~~~~

Comments

  • Hi,

    I see that a segfault isn't really a nice way of saying "don't do it this way".

    The right way is do let the main window create a view

    main_window = pya.MainWindow.instance()
    view_index = main_window.create_view()
    view = main_window.view(view_index)   # the LayoutView object
    

    A view can be a Widget embedded into other widgets, but it has a parent in this case. I guess the segfault is because there is no such parent.

    Matthias

  • Thank you so much!
    That worked :smile:

    Matthias

Sign In or Register to comment.