From ea6083c9802d6bdda8c8cb13a5fd261c7408d61d Mon Sep 17 00:00:00 2001 From: juha Date: Sat, 22 Jan 2011 16:01:10 +0000 Subject: [PATCH] Converter: Add cthreads only if not added already. git-svn-id: trunk@29162 - --- converter/usedunits.pas | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/converter/usedunits.pas b/converter/usedunits.pas index 63ceffa8d8..3133978660 100644 --- a/converter/usedunits.pas +++ b/converter/usedunits.pas @@ -634,18 +634,21 @@ function TUsedUnitsTool.AddThreadSupport: TModalResult; // AddUnitToSpecificUsesSection would insert cthreads in the beginning automatically // It doesn't work with {$IFDEF UNIX} directive -> use UsesInsertPolicy. var + i: Integer; OldPolicy: TUsesInsertPolicy; begin Result:=mrCancel; - with fCTLink do - try - OldPolicy:=SrcCache.BeautifyCodeOptions.UsesInsertPolicy; - SrcCache.BeautifyCodeOptions.UsesInsertPolicy:=uipFirst; - if not CodeTool.AddUnitToSpecificUsesSection(fMainUsedUnits.fUsesSection, - '{$IFDEF UNIX}cthreads{$ENDIF}', '', SrcCache) then exit; - finally - SrcCache.BeautifyCodeOptions.UsesInsertPolicy:=OldPolicy; - end; + if not ( fMainUsedUnits.fExistingUnits.Find('cthreads', i) or + fImplUsedUnits.fExistingUnits.Find('cthreads', i) ) then + with fCTLink do + try + OldPolicy:=SrcCache.BeautifyCodeOptions.UsesInsertPolicy; + SrcCache.BeautifyCodeOptions.UsesInsertPolicy:=uipFirst; + if not CodeTool.AddUnitToSpecificUsesSection(fMainUsedUnits.fUsesSection, + '{$IFDEF UNIX}cthreads{$ENDIF}', '', SrcCache) then exit; + finally + SrcCache.BeautifyCodeOptions.UsesInsertPolicy:=OldPolicy; + end; Result:=mrOK; end;