diff options
Diffstat (limited to 'UMain.pas')
| -rw-r--r-- | UMain.pas | 75 |
1 files changed, 42 insertions, 33 deletions
@@ -265,7 +265,7 @@ uses ULibc, UPreferences, UViewer, UToolTips, UMounterPrefs, UColumns, UTestPlugin, UConnectionManager, USearch, UProperties, URemoteWait, URunFromVFS, uVFSprototypes, UQuickConnect, - UConnectionProperties; + UConnectionProperties, UError; @@ -1125,7 +1125,8 @@ procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction); if not Assigned(Engine.ParentEngine) or (not (Engine is TVFSEngine)) then Exit; Result := Engine.ParentEngine; CheckForUnsavedConnection(Engine as TVFSEngine, False); - if not TVFSEngine(Engine).VFSClose then DebugMsg(['Error closing the engine...']); + if not TVFSEngine(Engine).VFSClose(nil) then + DebugMsg(['Error closing the engine...']); Engine.Free; end; @@ -1170,7 +1171,7 @@ begin if b then begin if (not LeftPanelNotebook.Visible) and (LeftPanelEngine is TVFSEngine) then begin while LeftPanelEngine is TVFSEngine do s := CloseVFS(True, True); - if LeftPanelEngine is TLocalTreeEngine then LeftPanelEngine.ChangeDir(s); + if LeftPanelEngine is TLocalTreeEngine then LeftPanelEngine.ChangeDir(s, nil); end else for i := 0 to LeftTabEngines.Count - 1 do if (TPanelEngine(LeftTabEngines[i]) <> nil) and (TPanelEngine(LeftTabEngines[i]) is TVFSEngine) then @@ -1189,7 +1190,7 @@ begin if (not RightPanelNotebook.Visible) and (RightPanelEngine is TVFSEngine) then begin while RightPanelEngine is TVFSEngine do s := CloseVFS(False, True); - if RightPanelEngine is TLocalTreeEngine then RightPanelEngine.ChangeDir(s); + if RightPanelEngine is TLocalTreeEngine then RightPanelEngine.ChangeDir(s, nil); end else for i := 0 to RightTabEngines.Count - 1 do if (TPanelEngine(RightTabEngines[i]) <> nil) and (TPanelEngine(RightTabEngines[i]) is TVFSEngine) then @@ -1872,26 +1873,25 @@ begin HiliString1 := ''; HiliString2 := ''; end; - if OpenDirThread.VFSOpenResult <> 0 then begin + if not OpenDirThread.VFSOpenResult then begin // Silence the error if password dialog has been cancelled if not OpenDirThread.VFSCallbackCancelled then - Application.MessageBox(LANGCouldntOpenURIArchive, [mbOK], mbError, mbOK, mbOK); + ShowError(Self, LANGCouldntOpenURIArchive, OpenDirThread.VFSOpenError); DebugMsg(['TFMain.ChangingDir: Freeing thread...']); OpenDirThread.Free; end else - if OpenDirThread.ChDirResult <> 0 then begin - if not OpenDirThread.VFSCallbackCancelled then begin - // Drop the error message if one of the callback dialogs were cancelled - if OpenDirThread.ChDirResult = 1 then Application.MessageBox(Format(LANGErrorGettingListingForSPanelNoPath, [LANGPanelStrings[LeftPanel], 'Exception']), [mbOK], mbError, mbNone, mbOK) - else Application.MessageBox(Format(LANGErrorGettingListingForSPanel, [LANGPanelStrings[LeftPanel], GetErrorString(OpenDirThread.ChDirResult), NewPath]), [mbOK], mbError, mbNone, mbOK); - end; + if not OpenDirThread.ChDirResult then begin + // Drop the error message if one of the callback dialogs were cancelled + if not OpenDirThread.VFSCallbackCancelled then + ShowError(Self, 'Error changing directory', OpenDirThread.ChDirError); + DebugMsg(['TFMain.ChangingDir: Freeing thread...']); + OpenDirThread.Free; + end else + if not OpenDirThread.ListingResult then begin + ShowError(Self, Format('Error getting listing for %s panel', [LANGPanelStrings[LeftPanel]]), OpenDirThread.ListingError); DebugMsg(['TFMain.ChangingDir: Freeing thread...']); OpenDirThread.Free; end else begin - if OpenDirThread.ListingResult <> 0 then begin - Application.MessageBox(Format(LANGErrorGettingListingForSPanel, [LANGPanelStrings[LeftPanel], GetErrorString(OpenDirThread.ListingResult), Engine.Path]), [mbOK], mbError, mbNone, mbOK); - Exit; - end; s := OpenDirThread.ASelItem; Engine := OpenDirThread.AEngine; // set current Engine from the thread (might have been modified due to VFS) if LeftPanel then LeftPanelEngine := Engine @@ -3607,7 +3607,7 @@ var s: string; // AViewer: TViewerThread; AViewer: TFViewer; begin - Stat := Engine.GetFileInfo(Filename, True, True); + Stat := Engine.GetFileInfo(Filename, True, True, nil); if Assigned(Stat) and (Stat^.Size > ConfEditViewFileSizeLimit) and (Application.MessageBox(LANGTheFileYouAreTryingToOpenIsQuiteBig, [mbYes, mbNo], mbWarning, mbNone, mbNo) = mbNo) then begin @@ -3710,7 +3710,7 @@ begin DebugMsg(['Some strange error occured...']); Exit; end; - Stat := Engine.GetFileInfo(Path, True, True); + Stat := Engine.GetFileInfo(Path, True, True, nil); if Assigned(Stat) and Stat^.IsExecutable then begin b := True; if Engine is TVFSEngine then b := HandleRunFromArchive(Path, Engine, Command, FileTypeDesc, False); // not a local engine, extract to local first @@ -4084,7 +4084,7 @@ begin if AFile <> '' then try FChmod := TFChmod.Create(Self); - Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True); + Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True, nil); if not Assigned(Stat) then Exit; UsrManager := TUserManager.Create; try @@ -4182,7 +4182,7 @@ begin if AFile <> '' then try FChown := TFChown.Create(Self); - Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True); + Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True, nil); if not Assigned(Stat) then Exit; FChown.AssignMode(Stat^.Mode, AFile, Stat^.UID, Stat^.GID); if FChown.Run = mbOK then begin @@ -4320,6 +4320,7 @@ var Item: TGTKMenuItem; UpDir, Found: boolean; i, j: integer; Assoc: TFileAssoc; + Error: PGError; begin ClearPopupMenu(FilePopupMenu); if LeftLastFocused then begin @@ -4333,9 +4334,11 @@ begin if Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and (not PDataItem(AListView.Selected.Data)^.UpDir) then FileName := FileName + PDataItem(AListView.Selected.Data)^.FName; ShortFName := ExtractFileName(ExcludeTrailingPathDelimiter(FileName)); - DataItem := Engine.GetFileInfo(FileName, True, True); + Error := nil; + DataItem := Engine.GetFileInfo(FileName, True, True, @Error); if not Assigned(DataItem) then begin - DebugMsg(['Error: File data not assigned. Bug ???! FileName = ', FileName]); + DebugMsg(['Error: File data not assigned. Bug ???! FileName = ', FileName, ', Error = ', Error^.message]); + g_error_free(Error); Exit; end; UpDir := PDataItem(AListView.Selected.Data)^.UpDir; @@ -4480,7 +4483,8 @@ var Engine: TPanelEngine; DataItem: PDataItem; AListView: TGTKListView; FileName, ShortFName, s: string; - Error: integer; + SpawnError: integer; + Error: PGError; b: boolean; begin try @@ -4501,9 +4505,11 @@ begin if Assigned(AListView.Selected) and Assigned(AListView.Selected.Data) and (not PDataItem(AListView.Selected.Data)^.UpDir) then FileName := FileName + PDataItem(AListView.Selected.Data)^.FName; ShortFName := ExtractFileName(ExcludeTrailingPathDelimiter(FileName)); - DataItem := Engine.GetFileInfo(FileName, True, True); + Error := nil; + DataItem := Engine.GetFileInfo(FileName, True, True, @Error); if not Assigned(DataItem) then begin - DebugMsg(['Error: File data not assigned. Bug ???! FileName = ', FileName]); + DebugMsg(['Error: File data not assigned. Bug ???! FileName = ', FileName, ', Error = ', Error^.message]); + g_error_free(Error); Exit; end; @@ -4514,7 +4520,7 @@ begin if Engine is TVFSEngine then b := HandleRunFromArchive(FileName, Engine, '', '', False); // not a local engine, extract to local first if b then begin libc_chdir(PChar(ExtractFilePath(FileName))); - b := ExecuteProgram(QuoteStr(FileName), ExtractFilePath(FileName), True, False, Error); + b := ExecuteProgram(QuoteStr(FileName), ExtractFilePath(FileName), True, False, SpawnError); libc_chdir(PChar('/')); end else b := True; // Mask cancelled extraction from VFS if not b then Application.MessageBox(LANGErrorExecutingCommand, [mbOK], mbError, mbNone, mbOK); @@ -4531,7 +4537,7 @@ begin if b then begin libc_chdir(PChar(ExtractFilePath(FileName))); b := ExecuteProgram(s, ExtractFilePath(FileName), TAssocAction((Sender as TGTKMenuItem).Data).AutodetectGUI, - TAssocAction((Sender as TGTKMenuItem).Data).RunInTerminal, Error); + TAssocAction((Sender as TGTKMenuItem).Data).RunInTerminal, SpawnError); libc_chdir(PChar('/')); end else b := True; // Mask cancelled extraction from VFS if not b then Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [FileName]), [mbOK], mbError, mbNone, mbOK); @@ -5392,7 +5398,7 @@ begin FTestPlugin := TFTestPlugin.Create(Self); if (FTestPlugin.Run = mbOK) and (PluginList.Count > 0) then begin Engine := TVFSEngine.Create(PluginList[FTestPlugin.PluginOptionMenu.ItemIndex]); - if not Engine.VFSOpenURI(FTestPlugin.CommandEntry.Text, nil, nil, nil, nil) then begin + if not Engine.VFSOpenURI(FTestPlugin.CommandEntry.Text, nil, nil, nil, nil, nil) then begin Application.MessageBox(LANGCouldntOpenURI, [mbOK], mbError, mbOK, mbOK); Exit; end; @@ -5728,7 +5734,8 @@ begin try xEngine := Engine; Engine := xEngine.ParentEngine; - if not TVFSEngine(xEngine).VFSClose then DebugMsg(['Error closing the engine...']); + if not TVFSEngine(xEngine).VFSClose(nil) then + DebugMsg(['Error closing the engine...']); xEngine.Free; except end; @@ -5756,7 +5763,8 @@ begin if (i <> TabNo) and (not CheckForUnsavedConnection(Engine as TVFSEngine, False)) then Exit; xEngine := Engine; Engine := xEngine.ParentEngine; - if not TVFSEngine(xEngine).VFSClose then DebugMsg(['Error closing the engine...']); + if not TVFSEngine(xEngine).VFSClose(nil) then + DebugMsg(['Error closing the engine...']); xEngine.Free; except end; end; @@ -6072,7 +6080,8 @@ begin if not SuppressRefresh then ChangingDir(LeftPanel, Engine.SavePath, Engine.ParentEngine.LastHighlightItem, Engine.ParentEngine.LastHighlightItem, False, True); - if not TVFSEngine(Engine).VFSClose then DebugMsg(['Error closing the engine...']); + if not TVFSEngine(Engine).VFSClose(nil) then + DebugMsg(['Error closing the engine...']); Engine.Free; end; @@ -6368,7 +6377,7 @@ begin if AFile <> '' then try FProperties := TFProperties.Create(Self); - Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True); + Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True, nil); if not Assigned(Stat) then Exit; // FProperties.AssignMode(Stat^.Mode, AFile, Stat^.UID, Stat^.GID); FProperties.DisplayFileName := AFile; @@ -6493,7 +6502,7 @@ begin Result := False; try if not BypassDialog then begin - Stat := Engine.GetFileInfo(APath, True, True); + Stat := Engine.GetFileInfo(APath, True, True, nil); FRunFromVFS := TFRunFromVFS.Create(Self); FRunFromVFS.FileNameLabel2.Caption := Format('%s<span weight="ultrabold"> </span>', [StrToUTF8(APath)]); if FileTypeDesc = '' then FileTypeDesc := LANGHandleRunFromArchive_FileTypeDesc_Unknown; |
