diff --git a/diylc/diylc-core/src/main/java/org/diylc/core/annotations/RequiredPositiveNonZeroMeasureValidator.java b/diylc/diylc-core/src/main/java/org/diylc/core/annotations/RequiredPositiveNonZeroMeasureValidator.java
new file mode 100644
index 000000000..e1cd215e1
--- /dev/null
+++ b/diylc/diylc-core/src/main/java/org/diylc/core/annotations/RequiredPositiveNonZeroMeasureValidator.java
@@ -0,0 +1,41 @@
+/*
+
+ DIY Layout Creator (DIYLC).
+ Copyright (c) 2009-2025 held jointly by the individual authors.
+
+ This file is part of DIYLC.
+
+ DIYLC is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ DIYLC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DIYLC. If not, see .
+
+*/
+package org.diylc.core.annotations;
+
+import org.diylc.core.ValidationException;
+
+/**
+ * Same as {@link PositiveNonZeroMeasureValidator}, but also rejects an empty value. Use it for
+ * measures the component cannot be drawn without.
+ *
+ * @author Branislav Stojkovic
+ */
+public class RequiredPositiveNonZeroMeasureValidator extends PositiveNonZeroMeasureValidator {
+
+ @Override
+ public void validate(Object owner, Object value) throws ValidationException {
+ if (value == null) {
+ throw new ValidationException("must not be empty.");
+ }
+ super.validate(owner, value);
+ }
+}
diff --git a/diylc/diylc-core/src/main/resources/update.xml b/diylc/diylc-core/src/main/resources/update.xml
index f091cccc9..fb25aec5d 100644
--- a/diylc/diylc-core/src/main/resources/update.xml
+++ b/diylc/diylc-core/src/main/resources/update.xml
@@ -637,6 +637,10 @@
BUG_FIX
Rotated labels in pasted components and building blocks were drawn in the wrong place and at the wrong angle while following the mouse, until the components were placed
+
+ BUG_FIX
+ Projects with a resistor, capacitor or other leaded component whose Width or Length had been cleared in the property editor could not be opened; such values now fall back to the default size, and Width and Length can no longer be left empty
+
https://github.com/bancika/diy-layout-creator/releases
diff --git a/diylc/diylc-library/src/main/java/org/diylc/components/AbstractLeadedComponent.java b/diylc/diylc-library/src/main/java/org/diylc/components/AbstractLeadedComponent.java
index 5701ef43a..d0682aa77 100644
--- a/diylc/diylc-library/src/main/java/org/diylc/components/AbstractLeadedComponent.java
+++ b/diylc/diylc-library/src/main/java/org/diylc/components/AbstractLeadedComponent.java
@@ -45,7 +45,7 @@ import org.diylc.common.ObjectCache;
import org.diylc.common.VerticalAlignment;
import org.diylc.core.*;
import org.diylc.core.annotations.EditableProperty;
-import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
+import org.diylc.core.annotations.RequiredPositiveNonZeroMeasureValidator;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.presenter.CalcUtils;
@@ -637,8 +637,12 @@ public abstract class AbstractLeadedComponent extends AbstractLabeledComponen
this.borderColor = borderColor;
}
- @EditableProperty(name = "Length", defaultable = true, validatorClass = PositiveNonZeroMeasureValidator.class, sortOrder = 101)
+ @EditableProperty(name = "Length", defaultable = true, validatorClass = RequiredPositiveNonZeroMeasureValidator.class, sortOrder = 101)
public Size getLength() {
+ // from 5.13 until this value became required, the property editor could clear it and files store null
+ if (length == null && getDefaultLength() != null) {
+ length = new Size(getDefaultLength().getValue(), getDefaultLength().getUnit());
+ }
return length;
}
@@ -672,8 +676,12 @@ public abstract class AbstractLeadedComponent extends AbstractLabeledComponen
}
}
- @EditableProperty(name = "Width", defaultable = true, validatorClass = PositiveNonZeroMeasureValidator.class, sortOrder = 102)
+ @EditableProperty(name = "Width", defaultable = true, validatorClass = RequiredPositiveNonZeroMeasureValidator.class, sortOrder = 102)
public Size getWidth() {
+ // from 5.13 until this value became required, the property editor could clear it and files store null
+ if (width == null && getDefaultWidth() != null) {
+ width = new Size(getDefaultWidth().getValue(), getDefaultWidth().getUnit());
+ }
return width;
}