From 329c3adda4a00358822280ef8097e83b4d1e0a10 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 13 Jun 2019 21:03:02 +0200 Subject: [PATCH] fix #479 - prevent the creation of a DUB property if laready present --- src/u_dubprojeditor.pas | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/u_dubprojeditor.pas b/src/u_dubprojeditor.pas index f2bdf1b8..07828906 100644 --- a/src/u_dubprojeditor.pas +++ b/src/u_dubprojeditor.pas @@ -412,13 +412,26 @@ end; procedure TDubProjectEditorWidget.addProp(const propName: string; tpe: TJSONtype); +const + w: string = 'The property %s is already present'; var + dat: TJSONData; arr: TJSONArray; obj: TJSONObject; nod: TTreeNode; begin if fSelectedNode.isNil then exit; + dat := TJSONData(fSelectedNode.Data); + if dat.JSONType = jtObject then + begin + obj := TJSONObject(dat); + if obj.findAny(propName, dat) then + begin + dlgOkInfo(format(w, [propName])); + exit; + end; + end; fProj.beginModification; if TJSONData(fSelectedNode.Data).JSONType = jtArray then begin @@ -459,7 +472,7 @@ begin exit; if fSelectedNode.Level = 0 then exit; - if fSelectedNode.Text = 'name' then + if (fSelectedNode.Text = 'name') and (fSelectedNode.Level = 0) then exit; if fSelectedNode.Data.isNil then exit;