Skip to content

Commit

Permalink
Bug 1558: Failure when creating local directory or deleting local fil…
Browse files Browse the repository at this point in the history
…es, while no session is connected

https://winscp.net/tracker/1558

Source commit: 988a7557e733179399721b49b8c3dcebba40373f
  • Loading branch information
martinprikryl committed Jan 28, 2018
1 parent feb9a98 commit 2920c37
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion source/core/Terminal.cpp
Expand Up @@ -3666,7 +3666,6 @@ bool __fastcall TTerminal::ProcessFiles(TStrings * FileList,
TFileOperation Operation, TProcessFileEvent ProcessFile, void * Param,
TOperationSide Side, bool Ex)
{
DebugAssert(FFileSystem);
DebugAssert(FileList);

bool Result = false;
Expand All @@ -3682,6 +3681,7 @@ bool __fastcall TTerminal::ProcessFiles(TStrings * FileList,
{
if (Side == osRemote)
{
DebugAssert(FFileSystem != NULL);
BeginTransaction();
}

Expand Down
6 changes: 3 additions & 3 deletions source/forms/CustomScpExplorer.cpp
Expand Up @@ -3680,7 +3680,6 @@ void __fastcall TCustomScpExplorerForm::SideEnter(TOperationSide Side)
void __fastcall TCustomScpExplorerForm::DeleteFiles(TOperationSide Side,
TStrings * FileList, bool Alternative)
{
DebugAssert(Terminal);
TCustomDirView * DView = DirView(Side);
DView->SaveSelection();
DView->SaveSelectedNames();
Expand All @@ -3691,13 +3690,14 @@ void __fastcall TCustomScpExplorerForm::DeleteFiles(TOperationSide Side,
{
if (Side == osRemote)
{
DebugAssert(Terminal != NULL);
Terminal->DeleteFiles(FileList, FLAGMASK(Alternative, dfAlternative));
}
else
{
try
{
Terminal->DeleteLocalFiles(FileList, FLAGMASK(Alternative, dfAlternative));
TTerminalManager::Instance()->LocalTerminal->DeleteLocalFiles(FileList, FLAGMASK(Alternative, dfAlternative));
}
__finally
{
Expand Down Expand Up @@ -3924,7 +3924,7 @@ void __fastcall TCustomScpExplorerForm::CreateDirectory(TOperationSide Side)
TRemoteProperties * AProperties = (Side == osRemote ? &Properties : NULL);
UnicodeString Name = LoadStr(NEW_FOLDER);
int AllowedChanges =
FLAGMASK(Terminal->IsCapable[fcModeChanging], cpMode);
FLAGMASK((Side == osRemote) && Terminal->IsCapable[fcModeChanging], cpMode);
bool SaveSettings = false;

if (DoCreateDirectoryDialog(Name, AProperties, AllowedChanges, SaveSettings))
Expand Down
29 changes: 19 additions & 10 deletions source/windows/TerminalManager.cpp
Expand Up @@ -93,6 +93,9 @@ __fastcall TTerminalManager::TTerminalManager() :
FTerminalList = new TStringList();
FQueues = new TList();
FTerminationMessages = new TStringList();
std::unique_ptr<TSessionData> DummyData(new TSessionData(L""));
FLocalTerminal = CreateTerminal(DummyData.get());
SetupTerminal(FLocalTerminal);
}
//---------------------------------------------------------------------------
__fastcall TTerminalManager::~TTerminalManager()
Expand All @@ -109,6 +112,7 @@ __fastcall TTerminalManager::~TTerminalManager()
DebugAssert(WinConfiguration->OnMasterPasswordPrompt == MasterPasswordPrompt);
WinConfiguration->OnMasterPasswordPrompt = NULL;

delete FLocalTerminal;
delete FQueues;
delete FTerminationMessages;
delete FTerminalList;
Expand Down Expand Up @@ -141,6 +145,20 @@ TTerminal * __fastcall TTerminalManager::CreateTerminal(TSessionData * Data)
return new TManagedTerminal(Data, Configuration);
}
//---------------------------------------------------------------------------
void __fastcall TTerminalManager::SetupTerminal(TTerminal * Terminal)
{
Terminal->OnQueryUser = TerminalQueryUser;
Terminal->OnPromptUser = TerminalPromptUser;
Terminal->OnDisplayBanner = TerminalDisplayBanner;
Terminal->OnShowExtendedException = TerminalShowExtendedException;
Terminal->OnProgress = OperationProgress;
Terminal->OnFinished = OperationFinished;
Terminal->OnDeleteLocalFile = DeleteLocalFile;
Terminal->OnReadDirectoryProgress = TerminalReadDirectoryProgress;
Terminal->OnInformation = TerminalInformation;
Terminal->OnCustomCommand = TerminalCustomCommand;
}
//---------------------------------------------------------------------------
TTerminal * __fastcall TTerminalManager::DoNewTerminal(TSessionData * Data)
{
FTerminalList->Clear();
Expand All @@ -150,16 +168,7 @@ TTerminal * __fastcall TTerminalManager::DoNewTerminal(TSessionData * Data)
FQueues->Add(NewQueue(Terminal));
FTerminationMessages->Add(L"");

Terminal->OnQueryUser = TerminalQueryUser;
Terminal->OnPromptUser = TerminalPromptUser;
Terminal->OnDisplayBanner = TerminalDisplayBanner;
Terminal->OnShowExtendedException = TerminalShowExtendedException;
Terminal->OnProgress = OperationProgress;
Terminal->OnFinished = OperationFinished;
Terminal->OnDeleteLocalFile = DeleteLocalFile;
Terminal->OnReadDirectoryProgress = TerminalReadDirectoryProgress;
Terminal->OnInformation = TerminalInformation;
Terminal->OnCustomCommand = TerminalCustomCommand;
SetupTerminal(Terminal);
}
catch(...)
{
Expand Down
3 changes: 3 additions & 0 deletions source/windows/TerminalManager.h
Expand Up @@ -71,6 +71,7 @@ class TTerminalManager : public TTerminalList
__property TStrings * TerminalList = { read = GetTerminalList };
__property TNotifyEvent OnLastTerminalClosed = { read = FOnLastTerminalClosed, write = FOnLastTerminalClosed };
__property TNotifyEvent OnTerminalListChanged = { read = FOnTerminalListChanged, write = FOnTerminalListChanged };
__property TTerminal * LocalTerminal = { read = FLocalTerminal };

protected:
virtual TTerminal * __fastcall CreateTerminal(TSessionData * Data);
Expand All @@ -79,6 +80,7 @@ class TTerminalManager : public TTerminalList
static TTerminalManager * FInstance;
TCustomScpExplorerForm * FScpExplorer;
TTerminal * FActiveTerminal;
TTerminal * FLocalTerminal;
bool FDestroying;
TTerminalPendingAction FTerminalPendingAction;
TNotifyEvent FOnLastTerminalClosed;
Expand Down Expand Up @@ -163,6 +165,7 @@ class TTerminalManager : public TTerminalList
bool __fastcall HandleMouseWheel(WPARAM WParam, LPARAM LParam);
void __fastcall DoConfigurationChange();
bool __fastcall ShouldDisplayQueueStatusOnAppTitle();
void __fastcall SetupTerminal(TTerminal * Terminal);
};
//---------------------------------------------------------------------------
#endif

0 comments on commit 2920c37

Please sign in to comment.