summaryrefslogtreecommitdiff
path: root/sci-electronics/ktechlab/files/ktechlab-0.50.0-crashfix-connectors-diverging.patch
diff options
context:
space:
mode:
Diffstat (limited to 'sci-electronics/ktechlab/files/ktechlab-0.50.0-crashfix-connectors-diverging.patch')
-rw-r--r--sci-electronics/ktechlab/files/ktechlab-0.50.0-crashfix-connectors-diverging.patch38
1 files changed, 38 insertions, 0 deletions
diff --git a/sci-electronics/ktechlab/files/ktechlab-0.50.0-crashfix-connectors-diverging.patch b/sci-electronics/ktechlab/files/ktechlab-0.50.0-crashfix-connectors-diverging.patch
new file mode 100644
index 000000000000..20222c89daab
--- /dev/null
+++ b/sci-electronics/ktechlab/files/ktechlab-0.50.0-crashfix-connectors-diverging.patch
@@ -0,0 +1,38 @@
+From 1b814b266f1bd25d92b701e071473f2267330933 Mon Sep 17 00:00:00 2001
+From: "Martin T. H. Sandsmark" <martin.sandsmark@kde.org>
+Date: Mon, 22 Mar 2021 12:49:26 +0100
+Subject: [PATCH] fix crash when looking for where connectors diverge
+
+---
+ src/electronics/ecnode.cpp | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/src/electronics/ecnode.cpp b/src/electronics/ecnode.cpp
+index 385844c1..28f2a556 100644
+--- a/src/electronics/ecnode.cpp
++++ b/src/electronics/ecnode.cpp
+@@ -225,10 +225,18 @@ QPoint ECNode::findConnectorDivergePoint(bool *found)
+ if (!gotP1 || !gotP2 )
+ return QPoint(0,0);
+
+- unsigned maxLength = p1.size() > p2.size() ? p1.size() : p2.size();
++ // If they are differing lengths, return the end of the shortest
++ if (p1.size() < p2.size()) {
++ *found = true;
++ return p1.last();
++ } else if (p2.size() < p1.size()) {
++ *found = true;
++ return p2.last();
++ }
++
++ Q_ASSERT(p1.size() == p2.size());
+
+- for ( unsigned i = 1; i < maxLength; ++i )
+- {
++ for (unsigned i = 1; i < qMin(p1.size(), p2.size()); ++i) {
+ if ( p1[i] != p2[i] ) {
+ *found = true;
+ return p1[i-1];
+--
+GitLab
+