mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Destroy the watcher at the appropriate time when needed in iCloudDrive
This commit is contained in:
parent
6371bf2df8
commit
97b8f1e4e6
1 changed files with 15 additions and 0 deletions
|
|
@ -81,6 +81,7 @@ type
|
|||
private
|
||||
procedure createWatcher;
|
||||
procedure destroyWatcher;
|
||||
procedure tryDestroyWatcher( data: PtrInt );
|
||||
function findWatch(const path: String; const event: TFSWatcherEvent): Integer;
|
||||
private
|
||||
function toFileSourceEvent( event: TDarwinFSWatchEvent;
|
||||
|
|
@ -202,6 +203,17 @@ begin
|
|||
FreeAndNil( _watcher );
|
||||
end;
|
||||
|
||||
procedure TiCloudDriveWatcher.tryDestroyWatcher( data: PtrInt );
|
||||
begin
|
||||
_lockObject.Acquire;
|
||||
try
|
||||
if _watcherItems.Count = 0 then
|
||||
destroyWatcher;
|
||||
finally
|
||||
_lockObject.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TiCloudDriveWatcher.findWatch(const path: String; const event: TFSWatcherEvent): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
|
|
@ -313,6 +325,8 @@ begin
|
|||
Exit;
|
||||
|
||||
_watcherItems.Delete( index );
|
||||
if _watcherItems.count = 0 then
|
||||
Application.QueueAsyncCall( @tryDestroyWatcher, PtrInt(self) );
|
||||
finally
|
||||
_lockObject.Release;
|
||||
end;
|
||||
|
|
@ -326,6 +340,7 @@ end;
|
|||
|
||||
destructor TiCloudDriveWatcher.Destroy;
|
||||
begin
|
||||
application.RemoveAsyncCalls( self );
|
||||
destroyWatcher;
|
||||
FreeAndNil( _watcherItems );
|
||||
FreeAndNil( _lockObject );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue