diff --git a/components/codetools/fileprocs.pas b/components/codetools/fileprocs.pas index 6c2863fbd4..af3dedd4ab 100644 --- a/components/codetools/fileprocs.pas +++ b/components/codetools/fileprocs.pas @@ -80,7 +80,8 @@ function FilenameIsTrimmed(StartPos: PChar; NameLen: integer): boolean; function TrimFilename(const AFilename: string): string; function CleanAndExpandFilename(const Filename: string): string; function CleanAndExpandDirectory(const Filename: string): string; -function CreateRelativePath(const Filename, BaseDirectory: string): string; +function CreateRelativePath(const Filename, BaseDirectory: string; + UsePointDirectory: boolean = false): string; function FileIsInPath(const Filename, Path: string): boolean; function AppendPathDelim(const Path: string): string; function ChompPathDelim(const Path: string): string; @@ -693,7 +694,7 @@ begin // check for double path delimiter if (StartPos[i]=PathDelim) then exit; - if StartPos[i]='.' then begin + if (StartPos[i]='.') and (i>0) then begin inc(i); // check /./ or /. at end if (StartPos[i]=PathDelim) or (i=NameLen) then exit; @@ -858,7 +859,8 @@ begin Result:=AppendPathDelim(CleanAndExpandFilename(Filename)); end; -function CreateRelativePath(const Filename, BaseDirectory: string): string; +function CreateRelativePath(const Filename, BaseDirectory: string; + UsePointDirectory: boolean): string; var FileNameLength: Integer; BaseDirLen: Integer; @@ -874,7 +876,7 @@ begin if (BaseDirectory='') or (Filename='') then exit; // check for different windows file drives if (CompareText(ExtractFileDrive(Filename), - ExtractFileDrive(BaseDirectory))<>0) + ExtractFileDrive(BaseDirectory))<>0) then exit; @@ -934,6 +936,10 @@ begin end; if FileNameRestLen>0 then Move(Filename[SamePos+1],Result[ResultPos],FileNameRestLen); + + // use '.' for an Filename=BaseDirectory + if (Result='') and (Filename<>'') and UsePointDirectory then + Result:='.'; end; {------------------------------------------------------------------------------ diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 90b76c81b0..b73891e144 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -2154,7 +2154,7 @@ Processor specific options: if UnitOutputDirectory<>'' then begin CurOutputDir:=ParsedOpts.GetParsedValue(pcosOutputDir); if not (cclAbsolutePaths in Flags) then - CurOutputDir:=CreateRelativePath(CurOutputDir,BaseDirectory); + CurOutputDir:=CreateRelativePath(CurOutputDir,BaseDirectory,true); end else CurOutputDir:=''; if CurOutputDir<>'' then @@ -2826,7 +2826,7 @@ begin else if Option in ParsedCompilerDirectories then begin // make directory absolute s:=TrimFilename(s); - if (s='') or (not FilenameIsAbsolute(s)) + if ((s='') or (not FilenameIsAbsolute(s))) and (Option<>pcosBaseDir) then begin if PlatformIndependent then BaseDirectory:=GetParsedPIValue(pcosBaseDir) diff --git a/ide/ideprocs.pp b/ide/ideprocs.pp index 5636aa17e3..1a01576994 100644 --- a/ide/ideprocs.pp +++ b/ide/ideprocs.pp @@ -87,7 +87,8 @@ function FilenameIsMatching(const Mask, Filename: string; function ConvertSpecialFileChars(const Filename: string): string; function FilenameIsPascalSource(const Filename: string): boolean; function FilenameIsFormText(const Filename: string): boolean; -function CreateRelativePath(const Filename, BaseDirectory: string): string; +function CreateRelativePath(const Filename, BaseDirectory: string; + UsePointDirectory: boolean = false): string; function SwitchPathDelims(const Filename: string; Switch: boolean): string; function ChompEndNumber(const s: string): string; @@ -640,9 +641,10 @@ begin end; end; -function CreateRelativePath(const Filename, BaseDirectory: string): string; +function CreateRelativePath(const Filename, BaseDirectory: string; + UsePointDirectory: boolean): string; begin - Result:=FileProcs.CreateRelativePath(Filename,BaseDirectory); + Result:=FileProcs.CreateRelativePath(Filename,BaseDirectory,UsePointDirectory); end; function CreateRelativeSearchPath(const SearchPath, BaseDirectory: string diff --git a/ide/main.pp b/ide/main.pp index 5b03255690..8850ad9336 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -2470,9 +2470,7 @@ begin DoExtractProcFromSelection; ecToggleMessages: - {$message warning TODO: toggle back to previously focused window?} - { DoShowMessageView does not bring messages view to top, source editor - is more important there } + // user used shortcut/menu item to show the window, so focusing is ok. MessagesView.EnsureVisible; ecToggleCodeExpl: @@ -4101,7 +4099,7 @@ begin AncestorInstance:=AncestorUnit.Component else AncestorInstance:=nil; - DebugLn(['TMainIDE.DoSaveUnitComponent AncestorInstance=',dbgsName(AncestorInstance)]); + //DebugLn(['TMainIDE.DoSaveUnitComponent AncestorInstance=',dbgsName(AncestorInstance)]); Writer.WriteDescendent(AnUnitInfo.Component,AncestorInstance); if DestroyDriver then Writer.Driver.Free; FreeAndNil(Writer); diff --git a/ideintf/objectinspector.pp b/ideintf/objectinspector.pp index 81364ffbe7..053468fd7d 100644 --- a/ideintf/objectinspector.pp +++ b/ideintf/objectinspector.pp @@ -1335,7 +1335,8 @@ begin Include(FStates,pgsChangingItemIndex); if (FItemIndex>=0) and (FItemIndexnil then begin @@ -1353,8 +1354,9 @@ begin NewRow:=Rows[NewIndex]; ScrollToItem(NewIndex); - - NewRow.Editor.Activate; + + if CanFocus then + NewRow.Editor.Activate; if paDialog in NewRow.Editor.GetAttributes then begin FCurrentButton:=ValueButton; FCurrentButton.Visible:=true; @@ -1392,7 +1394,8 @@ begin FCurrentEdit.Visible:=true; if (FDragging=false) and (FCurrentEdit.Showing) and FCurrentEdit.Enabled - and (not NewRow.IsReadOnly) then begin + and (not NewRow.IsReadOnly) + and CanFocus then begin if (Column=oipgcValue) then FCurrentEdit.SetFocus else diff --git a/lcl/include/customform.inc b/lcl/include/customform.inc index 330a8796ab..59aab9ba03 100644 --- a/lcl/include/customform.inc +++ b/lcl/include/customform.inc @@ -1185,10 +1185,9 @@ Begin if (AWinControl<>nil) then begin if (AWinControl=Self) or (GetParentForm(AWinControl)<>Self) - or ((not (csLoading in ComponentState)) - and (not AWinControl.CanFocus)) + or ((not (csLoading in ComponentState)) and (not AWinControl.CanFocus)) then begin - DebugLn('TCustomForm.SetActiveControl ',DbgSName(Self),' AWinControl=',DbgSName(AWinControl),' GetParentForm(AWinControl)=',DbgSName(GetParentForm(AWinControl)),' csLoading=',dbgs(csLoading in ComponentState),' AWinControl.CanFocus=',dbgs((AWinControl<>nil) and AWinControl.CanFocus)); + DebugLn('TCustomForm.SetActiveControl ',DbgSName(Self),' AWinControl=',DbgSName(AWinControl),' GetParentForm(AWinControl)=',DbgSName(GetParentForm(AWinControl)),' csLoading=',dbgs(csLoading in ComponentState),' AWinControl.CanFocus=',dbgs((AWinControl<>nil) and AWinControl.CanFocus),' IsControlVisible=',dbgs((AWinControl<>nil) and AWinControl.IsControlVisible),' Enabled=',dbgs((AWinControl<>nil) and AWinControl.Enabled),' GetParentForm(AWinControl)=',DbgSName(GetParentForm(AWinControl))); {$IFDEF VerboseFocus} RaiseGDBException(SCannotFocus); {$ELSE} diff --git a/lcl/include/fileutil.inc b/lcl/include/fileutil.inc index 4fc18576e6..4748ad4207 100644 --- a/lcl/include/fileutil.inc +++ b/lcl/include/fileutil.inc @@ -185,8 +185,9 @@ function TrimFilename(const AFilename: string): string; '.': if (i=1) or (TheFilename[i-1]=PathDelim) then begin - // check for . and .. directories - if (i=l) or (TheFilename[i+1]=PathDelim) then exit; + // check for . directories + if (TheFilename[i+1]=PathDelim) or ((i=l) and (i>1)) then exit; + // check for .. directories if (TheFilename[i+1]='.') and ((i=l-1) or (TheFilename[i+2]=PathDelim)) then exit; end;