Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c6cdea71
Commit
c6cdea71
authored
Nov 26, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
joy.cpl: Avoid race condition when accessing selected effect.
parent
b274278d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
main.c
dlls/joy.cpl/main.c
+38
-2
No files found.
dlls/joy.cpl/main.c
View file @
c6cdea71
...
...
@@ -105,6 +105,15 @@ struct JoystickData
static
HMODULE
hcpl
;
static
CRITICAL_SECTION
joy_cs
;
static
CRITICAL_SECTION_DEBUG
joy_cs_debug
=
{
0
,
0
,
&
joy_cs
,
{
&
joy_cs_debug
.
ProcessLocksList
,
&
joy_cs_debug
.
ProcessLocksList
},
0
,
0
,
{
(
DWORD_PTR
)(
__FILE__
": joy_cs"
)
}
};
static
CRITICAL_SECTION
joy_cs
=
{
&
joy_cs_debug
,
-
1
,
0
,
0
,
0
,
0
};
/*********************************************************************
* DllMain
*/
...
...
@@ -213,6 +222,27 @@ static BOOL CALLBACK enum_effects( const DIEFFECTINFOW *info, void *context )
return
DIENUM_CONTINUE
;
}
static
void
set_selected_effect
(
struct
Joystick
*
joystick
,
IDirectInputEffect
*
effect
)
{
IDirectInputEffect
*
previous
;
EnterCriticalSection
(
&
joy_cs
);
if
((
previous
=
joystick
->
effect_selected
))
IDirectInputEffect_Release
(
previous
);
if
((
joystick
->
effect_selected
=
effect
))
IDirectInput_AddRef
(
effect
);
LeaveCriticalSection
(
&
joy_cs
);
}
static
IDirectInputEffect
*
get_selected_effect
(
struct
Joystick
*
joystick
)
{
IDirectInputEffect
*
effect
;
EnterCriticalSection
(
&
joy_cs
);
if
((
effect
=
joystick
->
effect_selected
))
IDirectInputEffect_AddRef
(
effect
);
LeaveCriticalSection
(
&
joy_cs
);
return
effect
;
}
static
BOOL
CALLBACK
enum_callback
(
const
DIDEVICEINSTANCEW
*
instance
,
void
*
context
)
{
DIDEVCAPS
caps
=
{.
dwSize
=
sizeof
(
DIDEVCAPS
)};
...
...
@@ -277,6 +307,8 @@ static void destroy_joysticks(struct JoystickData *data)
{
struct
effect
*
effect
,
*
next_effect
;
set_selected_effect
(
&
data
->
joysticks
[
i
],
NULL
);
LIST_FOR_EACH_ENTRY_SAFE
(
effect
,
next_effect
,
&
data
->
joysticks
[
i
].
effects
,
struct
effect
,
entry
)
{
list_remove
(
&
effect
->
entry
);
...
...
@@ -867,6 +899,8 @@ static void ff_handle_effectchange(HWND hwnd, struct Joystick *joy)
struct
list
*
entry
;
int
sel
;
set_selected_effect
(
joy
,
NULL
);
sel
=
SendDlgItemMessageW
(
hwnd
,
IDC_FFEFFECTLIST
,
LB_GETCURSEL
,
0
,
0
);
if
(
sel
<
0
)
return
;
...
...
@@ -874,7 +908,7 @@ static void ff_handle_effectchange(HWND hwnd, struct Joystick *joy)
while
(
sel
--
&&
entry
)
entry
=
list_next
(
&
joy
->
effects
,
entry
);
if
(
!
entry
)
return
;
joy
->
effect_selected
=
LIST_ENTRY
(
entry
,
struct
effect
,
entry
)
->
effect
;
set_selected_effect
(
joy
,
LIST_ENTRY
(
entry
,
struct
effect
,
entry
)
->
effect
)
;
IDirectInputDevice8_Unacquire
(
joy
->
device
);
IDirectInputDevice8_SetCooperativeLevel
(
joy
->
device
,
GetAncestor
(
hwnd
,
GA_ROOT
),
DISCL_BACKGROUND
|
DISCL_EXCLUSIVE
);
...
...
@@ -908,7 +942,7 @@ static DWORD WINAPI ff_input_thread(void *param)
Sleep
(
TEST_POLL_TIME
);
if
(
!
(
effect
=
joy
->
effect_selected
))
continue
;
if
(
!
(
effect
=
get_selected_effect
(
joy
)
))
continue
;
poll_input
(
joy
,
&
state
);
...
...
@@ -930,6 +964,8 @@ static DWORD WINAPI ff_input_thread(void *param)
IDirectInputEffect_Start
(
effect
,
1
,
0
);
break
;
}
IDirectInputEffect_Release
(
effect
);
}
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment