summaryrefslogtreecommitdiff
path: root/UCore.pas
diff options
context:
space:
mode:
Diffstat (limited to 'UCore.pas')
-rw-r--r--UCore.pas14
1 files changed, 12 insertions, 2 deletions
diff --git a/UCore.pas b/UCore.pas
index 0fbfbb7..628b67a 100644
--- a/UCore.pas
+++ b/UCore.pas
@@ -157,6 +157,8 @@ type TWorkerThread = class(TThread)
VFSAskPassword_Display: boolean;
VFSAskPassword_Result: LongBool;
+ VFSCallbackCancelled: boolean;
+
constructor Create;
destructor Destroy; override;
end;
@@ -2610,6 +2612,7 @@ begin
VFSCallbackEvent := TSimpleEvent.Create;
VFSAskQuestion_Display := False;
VFSAskPassword_Display := False;
+ VFSCallbackCancelled := False;
end;
destructor TOpenDirThread.Destroy;
@@ -2630,6 +2633,7 @@ procedure TOpenDirThread.Execute;
var tt: TDateTime;
begin
FThreadID := pthread_self;
+ VFSCallbackCancelled := False;
try
// Writeln('execute.');
tt := Now;
@@ -2676,13 +2680,15 @@ end;
procedure vfs_ask_question_callback(const AMessage: PChar; const Choices: PPChar; choice: PInteger; user_data: Pointer); cdecl;
var Thread: TOpenDirThread;
begin
+ Thread := user_data;
+
if pthread_self = Application.ThreadID then begin
DebugMsg(['!! (WARNING): vfs_ask_question_callback called from the main thread, expected spawn from a OpenDirThread']);
HandleVFSAskQuestionCallback(FMain.FWidget, AMessage, Choices, choice);
+ if (choice <> nil) and (Thread <> nil) and (Thread is TOpenDirThread) then Thread.VFSCallbackCancelled := choice^ < 0;
Exit;
end;
- Thread := user_data;
if (Thread <> nil) and (Thread is TOpenDirThread) and (pthread_self = Thread.FThreadID) then begin
DebugMsg(['******* vfs_ask_question_callback spawned, user_data = 0x', IntToHex(QWord(user_data), 16), ', ThreadID = 0x', IntToHex(pthread_self, 16)]);
Thread.VFSAskQuestion_Message := AMessage;
@@ -2691,6 +2697,7 @@ begin
Thread.VFSAskQuestion_Display := True;
Thread.VFSCallbackEvent.WaitFor(INFINITE);
DebugMsg(['******* thread: resuming...']);
+ if (choice <> nil) then Thread.VFSCallbackCancelled := choice^ < 0;
Exit;
end;
@@ -2704,13 +2711,15 @@ function vfs_ask_password_callback(const AMessage: PChar; const default_user: PC
user_data: Pointer): LongBool; cdecl;
var Thread: TOpenDirThread;
begin
+ Thread := user_data;
+
if pthread_self = Application.ThreadID then begin
DebugMsg(['!! (WARNING): vfs_ask_password_callback called from the main thread, expected spawn from a OpenDirThread']);
Result := HandleVFSAskPasswordCallback(FMain.FWidget, AMessage, default_user, default_domain, flags, username, password, anonymous, domain, password_save);
+ if (Thread <> nil) and (Thread is TOpenDirThread) then Thread.VFSCallbackCancelled := Result = False;
Exit;
end;
- Thread := user_data;
if (Thread <> nil) and (Thread is TOpenDirThread) and (pthread_self = Thread.FThreadID) then begin
DebugMsg(['******* vfs_ask_password_callback spawned, user_data = 0x', IntToHex(QWord(user_data), 16), ', ThreadID = 0x', IntToHex(pthread_self, 16), ', Application.ThreadID = 0x', IntToHex(Application.ThreadID, 16)]);
Thread.VFSAskPassword_Message := AMessage;
@@ -2727,6 +2736,7 @@ begin
Thread.VFSCallbackEvent.WaitFor(INFINITE);
DebugMsg(['******* thread: resuming...']);
Result := Thread.VFSAskPassword_Result;
+ Thread.VFSCallbackCancelled := Result = False;
Exit;
end;