mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-30 03:27:44 +00:00
Merge pull request #13168 from keymanapp/feat/windows/13167/add-release-kmutex
refactor(windows): rename `TKeymanMutex.MutexOwned` to `TakeOwnership` and add `ReleaseOwnership`
This commit is contained in:
commit
8d6b331a67
4 changed files with 17 additions and 7 deletions
|
|
@ -526,12 +526,16 @@ begin
|
|||
fmMain, fmAbout:
|
||||
begin // I2720
|
||||
FMutex := TKeymanMutex.Create('KeymanConfiguration');
|
||||
if FMutex.MutexOwned then Main else FocusConfiguration;
|
||||
if FMutex.TakeOwnership
|
||||
then Main
|
||||
else FocusConfiguration;
|
||||
end;
|
||||
fmTextEditor:
|
||||
begin // I2720
|
||||
FMutex := TKeymanMutex.Create('KeymanTextEditor');
|
||||
if FMutex.MutexOwned then OpenTextEditor else FocusTextEditor;
|
||||
if FMutex.TakeOwnership
|
||||
then OpenTextEditor
|
||||
else FocusTextEditor;
|
||||
end;
|
||||
|
||||
fmBaseKeyboard: // I4169
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ begin
|
|||
begin
|
||||
FMutex := TKeymanMutex.Create('KeymanSplash');
|
||||
try
|
||||
if not FMutex.MutexOwned then
|
||||
if not FMutex.TakeOwnership then
|
||||
begin
|
||||
FocusSplash; // I2562
|
||||
Exit;
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ function TKeymanControl.IsConfigurationOpen: WordBool;
|
|||
begin
|
||||
with TKeymanMutex.Create('KeymanConfiguration') do
|
||||
try
|
||||
Result := MutexOwned;
|
||||
Result := not TakeOwnership;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
|
|
@ -302,7 +302,7 @@ function TKeymanControl.IsTextEditorOpen: WordBool;
|
|||
begin
|
||||
with TKeymanMutex.Create('KeymanTextEditor') do
|
||||
try
|
||||
Result := MutexOwned;
|
||||
Result := not TakeOwnership;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ type
|
|||
public
|
||||
constructor Create(FName: string);
|
||||
destructor Destroy; override;
|
||||
function MutexOwned: Boolean;
|
||||
function TakeOwnership: Boolean;
|
||||
function ReleaseOwnership: Boolean;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
|
@ -52,9 +53,14 @@ begin
|
|||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TKeymanMutex.MutexOwned: Boolean;
|
||||
function TKeymanMutex.TakeOwnership: Boolean;
|
||||
begin
|
||||
Result := WaitForSingleObject(hMutex, 0) = WAIT_OBJECT_0;
|
||||
end;
|
||||
|
||||
function TKeymanMutex.ReleaseOwnership: Boolean;
|
||||
begin
|
||||
Result := ReleaseMutex(hMutex);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue