From 9dba4d554f4cf44620037f2b0b663e85d412ed6e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 14 Apr 2021 00:32:12 +0200 Subject: [PATCH 1/2] Fix segfault when arranging without any disallowed areas So libnest2d is giving a segfault when it's being triggered without any disallowed areas. This is because we then give a single disallowed area for the border around the build plate, and give this disallowed area 0 vertices. Because libnest2d doesn't do defensive coding here, it's going to crash, taking Cura along with it. The crash is in libnest2d's function 'libnest2d::_Item::rightmostTopVertex()'. This segfault started happening recently in Cura. However it only happens when there are no disallowed areas. Steps to reproduce the error are: - Use Custom FFF Printer. - Set the Adhesion Type setting to 'None'. - Load any two models. I tracked the segfault down to this commit: https://github.com/Ultimaker/Uranium/pull/684/commits/74ddbaab4bb4737367ad2f82698ee7422305a047 . That commit by itself is slightly mysterious but looks fine to me. It did give the hint that this segfault might be caused by empty polygons though. So for that reason, I figured that filtering out the empty polygons here in the arranger might fix it; and indeed it does. Passing empty polygons as fixed/disallowed areas is useless and invalid anyway. Apparently libnest2d doesn't deal well with it, but we might as well not send those polygons over then. --- cura/Arranging/Nest2DArrange.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Arranging/Nest2DArrange.py b/cura/Arranging/Nest2DArrange.py index cdf590232c..334d920fde 100644 --- a/cura/Arranging/Nest2DArrange.py +++ b/cura/Arranging/Nest2DArrange.py @@ -75,7 +75,7 @@ def findNodePlacement(nodes_to_arrange: List["SceneNode"], build_volume: "BuildV # Clip the disallowed areas so that they don't overlap the bounding box (The arranger chokes otherwise) clipped_area = area.intersectionConvexHulls(build_plate_polygon) - if clipped_area.getPoints() is not None: # numpy array has to be explicitly checked against None + if clipped_area.getPoints() is not None and len(clipped_area.getPoints()) > 2: # numpy array has to be explicitly checked against None for point in clipped_area.getPoints(): converted_points.append(Point(int(point[0] * factor), int(point[1] * factor))) @@ -88,7 +88,7 @@ def findNodePlacement(nodes_to_arrange: List["SceneNode"], build_volume: "BuildV converted_points = [] hull_polygon = node.callDecoration("getConvexHull") - if hull_polygon is not None and hull_polygon.getPoints() is not None: # numpy array has to be explicitly checked against None + if hull_polygon is not None and hull_polygon.getPoints() is not None and len(hull_polygon.getPoints()) > 2: # numpy array has to be explicitly checked against None for point in hull_polygon.getPoints(): converted_points.append(Point(point[0] * factor, point[1] * factor)) item = Item(converted_points) From 45f5a222f0e0cc90158a0d6309c9ea95f3ea9118 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 14 Apr 2021 10:58:05 +0200 Subject: [PATCH 2/2] Downgrade version of certain qml impots to as low as they need to be --- resources/qml/Menus/SettingVisibilityPresetsMenu.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Menus/SettingVisibilityPresetsMenu.qml b/resources/qml/Menus/SettingVisibilityPresetsMenu.qml index fdd78ab42d..e2bb6b2a56 100644 --- a/resources/qml/Menus/SettingVisibilityPresetsMenu.qml +++ b/resources/qml/Menus/SettingVisibilityPresetsMenu.qml @@ -2,8 +2,8 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10 -import QtQuick.Controls 2.15 -import QtQml.Models 2.15 as Models +import QtQuick.Controls 2.11 +import QtQml.Models 2.14 as Models import UM 1.2 as UM import Cura 1.0 as Cura