Skip to content

Commit 25d0d04

Browse files
committed
Circuit: adjust SetActiveElement to behave closer to the upstream version.
1 parent 791da72 commit 25d0d04

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

docs/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
## Version 0.14.3 (next, unreleased)
2121

2222
- API/YMatrix: check for valid circuit in a few more functions.
23+
- API/Circuit: adjust `SetActiveElement` to be more conformant with the official version, i.e., returns -1 for non-circuit elements.
2324

2425
## Version 0.14.2 (2024-02-26)
2526

src/Common/Circuit.pas

+4-4
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ function TDSSCircuit.SetElementActive(const FullObjectName: String): Integer;
20152015
DevType,
20162016
DevName: String;
20172017
DevCls: TDSSClass;
2018-
element: TDSSCktElement;
2018+
element: TDSSObject;
20192019
begin
20202020
Result := 0;
20212021
ParseObjectClassandName(DSS, FullObjectName, DevType, DevName);
@@ -2029,12 +2029,12 @@ function TDSSCircuit.SetElementActive(const FullObjectName: String): Integer;
20292029

20302030
if not DuplicatesAllowed then
20312031
begin
2032-
element := TDSSCktElement(DevCls.Find(DevName, FALSE));
2033-
if element <> NIL then
2032+
element := DevCls.Find(DevName, FALSE);
2033+
if (element <> NIL) and (element is TDSSCktElement) then
20342034
begin
20352035
DSS.ActiveDSSClass := DSS.DSSClassList.Get(DevClassIndex);
20362036
DSS.LastClassReferenced := DevClassIndex;
2037-
Result := element.Handle;
2037+
Result := TDSSCktElement(element).Handle;
20382038
ActiveCktElement := CktElements.Get(Result);
20392039
end;
20402040
end

0 commit comments

Comments
 (0)