From 1d47d3d54ac9460f392768fb26dc8e0ae10bfd5a Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 3 Dec 2009 10:59:32 +0000 Subject: [PATCH] IDE: when no lps file: open main unit git-svn-id: trunk@22939 - --- components/codetools/examples/addclass.lpi | 7 ++-- .../codetools/examples/addeventmethod.lpi | 2 ++ components/codetools/examples/addmethod.lpi | 2 ++ .../codetools/examples/codecompletion.lpi | 6 ++-- .../examples/completeabstractmethods.lpi | 14 ++++---- ide/project.pp | 32 +++++++++++-------- 6 files changed, 35 insertions(+), 28 deletions(-) diff --git a/components/codetools/examples/addclass.lpi b/components/codetools/examples/addclass.lpi index 79a83923be..e4fbb82c50 100644 --- a/components/codetools/examples/addclass.lpi +++ b/components/codetools/examples/addclass.lpi @@ -24,13 +24,10 @@ - + - - - - + diff --git a/components/codetools/examples/addeventmethod.lpi b/components/codetools/examples/addeventmethod.lpi index f3945460c0..dff6a5a3a6 100644 --- a/components/codetools/examples/addeventmethod.lpi +++ b/components/codetools/examples/addeventmethod.lpi @@ -4,6 +4,8 @@ + + diff --git a/components/codetools/examples/addmethod.lpi b/components/codetools/examples/addmethod.lpi index e64ccffcb6..a9dac16c92 100644 --- a/components/codetools/examples/addmethod.lpi +++ b/components/codetools/examples/addmethod.lpi @@ -4,6 +4,8 @@ + + diff --git a/components/codetools/examples/codecompletion.lpi b/components/codetools/examples/codecompletion.lpi index 0edfb626f9..3d1ca60ac3 100644 --- a/components/codetools/examples/codecompletion.lpi +++ b/components/codetools/examples/codecompletion.lpi @@ -1,9 +1,11 @@ - - + + + + diff --git a/components/codetools/examples/completeabstractmethods.lpi b/components/codetools/examples/completeabstractmethods.lpi index 07eb1a1ada..81a4ef3064 100644 --- a/components/codetools/examples/completeabstractmethods.lpi +++ b/components/codetools/examples/completeabstractmethods.lpi @@ -1,12 +1,15 @@ - - + + + + + + - @@ -39,13 +42,10 @@ - + - - - diff --git a/ide/project.pp b/ide/project.pp index c086fc4201..73a90a30c3 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -2450,23 +2450,27 @@ var BestUnitInfo:=nil; - if (MainUnitID>=0) - and ([pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]*Flags=[]) - then begin - // the main unit contains no automatic statements - // open the main unit - BestUnitInfo:=MainUnitInfo; + if (MainUnitID>=0) then begin + if Requires(PackageGraph.LCLPackage,true) + and (Flags*[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]<>[]) + then begin + // this is a probably a LCL project where the main source only contains + // automatic code + end else + BestUnitInfo:=MainUnitInfo; end; - AnUnitInfo:=FirstPartOfProject; - while AnUnitInfo<>nil do begin - if (BestUnitInfo=nil) - or (FilenameIsPascalUnit(AnUnitInfo.Filename) - and (not FilenameIsPascalUnit(BestUnitInfo.Filename))) - then begin - BestUnitInfo:=AnUnitInfo; + if BestUnitInfo=nil then begin + AnUnitInfo:=FirstPartOfProject; + while AnUnitInfo<>nil do begin + if (BestUnitInfo=nil) + or (FilenameIsPascalUnit(AnUnitInfo.Filename) + and (not FilenameIsPascalUnit(BestUnitInfo.Filename))) + then begin + BestUnitInfo:=AnUnitInfo; + end; + AnUnitInfo:=AnUnitInfo.NextPartOfProject; end; - AnUnitInfo:=AnUnitInfo.NextPartOfProject; end; if BestUnitInfo<>nil then begin BestUnitInfo.EditorIndex:=0;