Subversion Repositories fastphp

Rev

Rev 72 | Rev 76 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 72 Rev 75
Line 943... Line 943...
943
  begin
943
  begin
944
    FreeAndNil(ChmIndex);
944
    FreeAndNil(ChmIndex);
945
  end;
945
  end;
946
  FreeAndNil(SrcRep);
946
  FreeAndNil(SrcRep);
947
 
947
 
948
  if hMutex <> 0 then CloseHandle(hMutex);
948
  if hMutex <> 0 then CloseHandle(hMutex); // Note: ReleaseMutex does not work as expected!
949
 
949
 
950
  if Assigned(codeExplorer) then
950
  if Assigned(codeExplorer) then
951
  begin
951
  begin
952
    codeExplorer.Terminate;
952
    codeExplorer.Terminate;
953
    codeExplorer.WaitFor;
953
    codeExplorer.WaitFor;
Line 988... Line 988...
988
 
988
 
989
  if FileExists(ScrapFile) then
989
  if FileExists(ScrapFile) then
990
  begin
990
  begin
991
    if hMutex = 0 then
991
    if hMutex = 0 then
992
    begin
992
    begin
993
      hMutex := CreateMutex(nil, True, PChar('FastPHP'+md5(ScrapFile)));
993
      hMutex := CreateMutex(nil, True, PChar('FastPHP'+md5(UpperCase(ScrapFile))));
994
      if GetLastError = ERROR_ALREADY_EXISTS then
994
      if GetLastError = ERROR_ALREADY_EXISTS then
995
      begin
995
      begin
996
        // TODO: It would be great if the window of that FastPHP instance would switched to foreground
996
        // TODO: It would be great if the window of that FastPHP instance would switched to foreground
997
        ShowMessageFmt('File "%s" is alrady open!', [ScrapFile]);
997
        ShowMessageFmt('File "%s" is alrady open!', [ScrapFile]);
998
        Close;
998
        Close;
Line 1023... Line 1023...
1023
begin
1023
begin
1024
  Button7.Click;
1024
  Button7.Click;
1025
end;
1025
end;
1026
 
1026
 
1027
procedure TForm1.Saveas1Click(Sender: TObject);
1027
procedure TForm1.Saveas1Click(Sender: TObject);
-
 
1028
var
-
 
1029
  hMutexNew: THandle;
1028
begin
1030
begin
1029
  if SaveDialog1.Execute then
1031
  if SaveDialog1.Execute then
1030
  begin
1032
  begin
-
 
1033
    {$REGION 'Switch mutex'}
-
 
1034
    hMutexNew := CreateMutex(nil, True, PChar('FastPHP'+md5(UpperCase(SaveDialog1.FileName))));
-
 
1035
    if GetLastError = ERROR_ALREADY_EXISTS then
-
 
1036
    begin
-
 
1037
      ShowMessageFmt('Cannot save because file "%s", because it is alrady open in another FastPHP window!', [SaveDialog1.FileName]);
-
 
1038
      Close;
-
 
1039
    end;
-
 
1040
 
-
 
1041
    if hMutex <> 0 then CloseHandle(hMutex); // Note: ReleaseMutex does not work as expected!
-
 
1042
    hMutex := hMutexNew;
-
 
1043
    {$ENDREGION}
-
 
1044
 
1031
    FSaveAsFilename := SaveDialog1.FileName;
1045
    FSaveAsFilename := SaveDialog1.FileName;
1032
    Caption := Copy(Caption, 1, Pos(' - ', Caption)-1) + ' - ' + FSaveAsFilename;
1046
    Caption := Copy(Caption, 1, Pos(' - ', Caption)-1) + ' - ' + FSaveAsFilename;
1033
    Button7.Click;
1047
    Button7.Click;
1034
  end;
1048
  end;
1035
end;
1049
end;