abey79 / vpype

The Swiss-Army-knife command-line tool for plotter vector graphics.
https://vpype.readthedocs.io/
MIT License
703 stars 62 forks source link

When presented with an empty layer, the viewer fails to show anything #338

Closed cbmoore closed 2 years ago

cbmoore commented 2 years ago

If (for instance) a crop causes one of the layers to be empty, a subsequent show will result in the viewing failing (hangs with a black window).

abey79 commented 2 years ago

Thanks for the feedback. Can you provide the traceback? Due to #320 I'm currently limited in my ability to run the viewer.

cbmoore commented 2 years ago

Traceback:


qt.qpa.window: <QNSWindow: 0x7f87f9d0dd70; contentView=<QNSView: 0x7f87f9d06470; QCocoaWindow(0x7f87f98a6c80, window=QWidgetWindow(0x7f87f9af50c0, name="QGLWidgetClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.
qt.qpa.window: <QNSWindow: 0x7f87f9d38720; contentView=<QNSView: 0x7f87f9d06470; QCocoaWindow(0x7f87f98a6c80, window=QWidgetWindow(0x7f87f9af50c0, name="QGLWidgetClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.
qt.qpa.window: <QNSWindow: 0x7f87f9c7a310; contentView=<QNSView: 0x7f87f9c79cf0; QCocoaWindow(0x7f87f9c79c40, window=QWidgetWindow(0x7f87f9c763c0, name="QWidgetClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/qtviewer/viewer.py", line 135, in paintGL
    self.engine.render()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 387, in render
    self._rebuild()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 444, in _rebuild
    LineCollectionPreviewPainter(
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 289, in __init__
    vertices, indices = self._build_buffers(lc)
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 338, in _build_buffers
    np.vstack([vp.as_vector(line).astype("f4") for line in lc]),
  File "<__array_function__ internals>", line 5, in vstack
  File "/usr/local/lib/python3.9/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: need at least one array to concatenate
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/qtviewer/viewer.py", line 135, in paintGL
    self.engine.render()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 387, in render
    self._rebuild()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 444, in _rebuild
    LineCollectionPreviewPainter(
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 289, in __init__
    vertices, indices = self._build_buffers(lc)
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 338, in _build_buffers
    np.vstack([vp.as_vector(line).astype("f4") for line in lc]),
  File "<__array_function__ internals>", line 5, in vstack
  File "/usr/local/lib/python3.9/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: need at least one array to concatenate
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/qtviewer/viewer.py", line 135, in paintGL
    self.engine.render()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 387, in render
    self._rebuild()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 444, in _rebuild
    LineCollectionPreviewPainter(
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 289, in __init__
    vertices, indices = self._build_buffers(lc)
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 338, in _build_buffers
    np.vstack([vp.as_vector(line).astype("f4") for line in lc]),
  File "<__array_function__ internals>", line 5, in vstack
  File "/usr/local/lib/python3.9/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: need at least one array to concatenate
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/qtviewer/viewer.py", line 135, in paintGL
    self.engine.render()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 387, in render
    self._rebuild()
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/engine.py", line 444, in _rebuild
    LineCollectionPreviewPainter(
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 289, in __init__
    vertices, indices = self._build_buffers(lc)
  File "/usr/local/lib/python3.9/site-packages/vpype_viewer/_painters.py", line 338, in _build_buffers
    np.vstack([vp.as_vector(line).astype("f4") for line in lc]),
  File "<__array_function__ internals>", line 5, in vstack
  File "/usr/local/lib/python3.9/site-packages/numpy/core/shape_base.py", line 283, in vstack
    return _nx.concatenate(arrs, 0)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: need at least one array to concatenate```
abey79 commented 2 years ago

If I may, for readability, please use triple back-quote instead of single-quote so that line breaks aren't lost.

cbmoore commented 2 years ago

Ah--much better. thanks!