Browse Source

* fix bug report 2094 by restoring nonamexx.pas name if file name is incorrect

pierre 23 years ago
parent
commit
f1ff265924
1 changed files with 25 additions and 10 deletions
  1. 25 10
      ide/fpviews.pas

+ 25 - 10
ide/fpviews.pas

@@ -167,6 +167,7 @@ type
     TSourceWindow = object(TFPWindow)
     TSourceWindow = object(TFPWindow)
       Editor    : PSourceEditor;
       Editor    : PSourceEditor;
       Indicator : PIndicator;
       Indicator : PIndicator;
+      NoNameCount : longint;
       constructor Init(var Bounds: TRect; AFileName: string);
       constructor Init(var Bounds: TRect; AFileName: string);
       function    GetTitle(MaxSize: sw_Integer): TTitleStr; virtual;
       function    GetTitle(MaxSize: sw_Integer): TTitleStr; virtual;
       procedure   SetTitle(ATitle: string); virtual;
       procedure   SetTitle(ATitle: string); virtual;
@@ -605,7 +606,7 @@ const
      Store:   @TDisassemblyWindow.Store
      Store:   @TDisassemblyWindow.Store
   );
   );
 const
 const
-  NoNameCount    : integer = 0;
+  GlobalNoNameCount : integer = 0;
 var
 var
   ReservedWords  : array[1..ReservedWordMaxLen] of PStringCollection;
   ReservedWords  : array[1..ReservedWordMaxLen] of PStringCollection;
   AsmReservedWords  : array[1..ReservedWordMaxLen] of PStringCollection;
   AsmReservedWords  : array[1..ReservedWordMaxLen] of PStringCollection;
@@ -1692,7 +1693,12 @@ begin
   GetExtent(R); R.Grow(-1,-1);
   GetExtent(R); R.Grow(-1,-1);
   LoadFile:=AFileName<>'';
   LoadFile:=AFileName<>'';
   if not LoadFile then
   if not LoadFile then
-     begin SetTitle('noname'+IntToStrZ(NonameCount,2)+'.pas'); Inc(NonameCount); end;
+    begin
+      Inc(GlobalNoNameCount);
+      NoNameCount:=GlobalNoNameCount;
+    end
+  else
+    NoNameCount:=0;
   New(Editor, Init(R, HSB, VSB, Indicator,AFileName));
   New(Editor, Init(R, HSB, VSB, Indicator,AFileName));
   Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
   Editor^.GrowMode:=gfGrowHiX+gfGrowHiY;
   if LoadFile then
   if LoadFile then
@@ -1719,15 +1725,19 @@ var Name: string;
     Count: sw_integer;
     Count: sw_integer;
 begin
 begin
   if Editor^.FileName<>'' then
   if Editor^.FileName<>'' then
-  begin
-    Name:=SmartPath(Editor^.FileName);
-    Count:=Editor^.Core^.GetBindingCount;
-    if Count>1 then
     begin
     begin
-      Name:=Name+':'+IntToStr(Editor^.Core^.GetBindingIndex(Editor)+1);
+      Name:=SmartPath(Editor^.FileName);
+      Count:=Editor^.Core^.GetBindingCount;
+      if Count>1 then
+      begin
+        Name:=Name+':'+IntToStr(Editor^.Core^.GetBindingIndex(Editor)+1);
+      end;
+      SetTitle(Name);
+    end
+  else if NoNameCount>0 then
+    begin
+      SetTitle('noname'+IntToStrZ(NonameCount,2)+'.pas');
     end;
     end;
-    SetTitle(Name);
-  end;
 end;
 end;
 
 
 function TSourceWindow.GetTitle(MaxSize: sw_Integer): TTitleStr;
 function TSourceWindow.GetTitle(MaxSize: sw_Integer): TTitleStr;
@@ -2393,6 +2403,8 @@ var R: TRect;
 begin
 begin
   Desktop^.GetExtent(R);
   Desktop^.GetExtent(R);
   inherited Init(R, '');
   inherited Init(R, '');
+  NoNameCount:=0;
+  Dec(GlobalNoNameCount);
   SetTitle(dialog_clipboard);
   SetTitle(dialog_clipboard);
   HelpCtx:=hcClipboardWindow;
   HelpCtx:=hcClipboardWindow;
   Number:=wnNoNumber;
   Number:=wnNoNumber;
@@ -4218,7 +4230,10 @@ end;
 END.
 END.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2002-06-13 11:52:01  pierre
+  Revision 1.24  2002-08-26 13:00:08  pierre
+   * fix bug report 2094 by restoring nonamexx.pas name if file name is incorrect
+
+  Revision 1.23  2002/06/13 11:52:01  pierre
    * try to avoid crash with fvision library
    * try to avoid crash with fvision library
 
 
   Revision 1.22  2002/06/13 10:54:54  pierre
   Revision 1.22  2002/06/13 10:54:54  pierre