Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
915174d8
Commit
915174d8
authored
Jul 10, 2006
by
Stefan Dösinger
Committed by
Alexandre Julliard
Jul 11, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Palette refcounting fix.
Do not AddRef the DirectDraw interfaces in CreatePalette of older interface version, and add a test for that.
parent
0a812957
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
19 deletions
+70
-19
ddraw.c
dlls/ddraw/ddraw.c
+1
-0
ddraw_private.h
dlls/ddraw/ddraw_private.h
+1
-0
ddraw_thunks.c
dlls/ddraw/ddraw_thunks.c
+14
-4
palette.c
dlls/ddraw/palette.c
+6
-1
refcount.c
dlls/ddraw/tests/refcount.c
+48
-14
No files found.
dlls/ddraw/ddraw.c
View file @
915174d8
...
...
@@ -3007,6 +3007,7 @@ IDirectDrawImpl_CreatePalette(IDirectDraw7 *iface,
}
IDirectDraw7_AddRef
(
iface
);
object
->
ifaceToRelease
=
(
IUnknown
*
)
iface
;
*
Palette
=
ICOM_INTERFACE
(
object
,
IDirectDrawPalette
);
return
DD_OK
;
}
...
...
dlls/ddraw/ddraw_private.h
View file @
915174d8
...
...
@@ -393,6 +393,7 @@ struct IDirectDrawPaletteImpl
/* IDirectDrawPalette fields */
IDirectDrawImpl
*
ddraw_owner
;
IUnknown
*
ifaceToRelease
;
};
const
IDirectDrawPaletteVtbl
IDirectDrawPalette_Vtbl
;
...
...
dlls/ddraw/ddraw_thunks.c
View file @
915174d8
...
...
@@ -236,10 +236,13 @@ IDirectDrawImpl_CreatePalette(LPDIRECTDRAW This, DWORD dwFlags,
dwFlags
,
pEntries
,
ppPalette
,
pUnkOuter
);
if
(
SUCCEEDED
(
hr
)
&&
*
ppPalette
)
{
IDirectDrawPaletteImpl
*
impl
=
ICOM_OBJECT
(
IDirectDrawPaletteImpl
,
IDirectDrawPalette
,
*
ppPalette
);
IDirectDraw7_Release
(
COM_INTERFACE_CAST
(
IDirectDrawImpl
,
IDirectDraw
,
IDirectDraw7
,
This
));
impl
->
ifaceToRelease
=
NULL
;
}
return
hr
;
}
...
...
@@ -251,18 +254,21 @@ IDirectDraw2Impl_CreatePalette(LPDIRECTDRAW2 This, DWORD dwFlags,
IUnknown
*
pUnkOuter
)
{
HRESULT
hr
;
return
IDirectDraw7_CreatePalette
(
COM_INTERFACE_CAST
(
IDirectDrawImpl
,
hr
=
IDirectDraw7_CreatePalette
(
COM_INTERFACE_CAST
(
IDirectDrawImpl
,
IDirectDraw2
,
IDirectDraw7
,
This
),
dwFlags
,
pEntries
,
ppPalette
,
pUnkOuter
);
if
(
SUCCEEDED
(
hr
)
&&
*
ppPalette
)
{
IDirectDrawPaletteImpl
*
impl
=
ICOM_OBJECT
(
IDirectDrawPaletteImpl
,
IDirectDrawPalette
,
*
ppPalette
);
IDirectDraw7_Release
(
COM_INTERFACE_CAST
(
IDirectDrawImpl
,
IDirectDraw
,
IDirectDraw
2
,
IDirectDraw7
,
This
));
impl
->
ifaceToRelease
=
NULL
;
}
return
hr
;
}
static
HRESULT
WINAPI
...
...
@@ -272,18 +278,22 @@ IDirectDraw4Impl_CreatePalette(LPDIRECTDRAW4 This, DWORD dwFlags,
IUnknown
*
pUnkOuter
)
{
HRESULT
hr
;
return
IDirectDraw7_CreatePalette
(
COM_INTERFACE_CAST
(
IDirectDrawImpl
,
hr
=
IDirectDraw7_CreatePalette
(
COM_INTERFACE_CAST
(
IDirectDrawImpl
,
IDirectDraw4
,
IDirectDraw7
,
This
),
dwFlags
,
pEntries
,
ppPalette
,
pUnkOuter
);
if
(
SUCCEEDED
(
hr
)
&&
*
ppPalette
)
{
IDirectDrawPaletteImpl
*
impl
=
ICOM_OBJECT
(
IDirectDrawPaletteImpl
,
IDirectDrawPalette
,
*
ppPalette
);
IDirectDraw7_Release
(
COM_INTERFACE_CAST
(
IDirectDrawImpl
,
IDirectDraw
,
IDirectDraw
4
,
IDirectDraw7
,
This
));
IDirectDraw4_AddRef
(
This
);
impl
->
ifaceToRelease
=
(
IUnknown
*
)
This
;
}
return
hr
;
}
static
HRESULT
WINAPI
...
...
dlls/ddraw/palette.c
View file @
915174d8
...
...
@@ -21,6 +21,8 @@
#include "winerror.h"
#include "wine/debug.h"
#define COBJMACROS
#include <assert.h>
#include <string.h>
...
...
@@ -104,7 +106,10 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
if
(
ref
==
0
)
{
IWineD3DPalette_Release
(
This
->
wineD3DPalette
);
IDirectDraw7_Release
(
ICOM_INTERFACE
(
This
->
ddraw_owner
,
IDirectDraw7
));
if
(
This
->
ifaceToRelease
)
{
IUnknown_Release
(
This
->
ifaceToRelease
);
}
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
dlls/ddraw/tests/refcount.c
View file @
915174d8
...
...
@@ -47,32 +47,42 @@ static void test_ddraw_objects(void)
{
HRESULT
hr
;
unsigned
long
ref
;
IDirectDraw7
*
DDraw
;
IDirectDraw7
*
DDraw7
;
IDirectDraw4
*
DDraw4
;
IDirectDraw4
*
DDraw2
;
IDirectDraw4
*
DDraw1
;
IDirectDrawPalette
*
palette
;
IDirectDrawSurface7
*
surface
;
PALETTEENTRY
Table
[
256
];
DDSURFACEDESC2
ddsd
;
hr
=
pDirectDrawCreateEx
(
NULL
,
(
void
**
)
&
DDraw
,
&
IID_IDirectDraw7
,
NULL
);
hr
=
pDirectDrawCreateEx
(
NULL
,
(
void
**
)
&
DDraw
7
,
&
IID_IDirectDraw7
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_NODIRECTDRAWSUPPORT
,
"DirectDrawCreateEx returned: %lx
\n
"
,
hr
);
if
(
!
DDraw
)
if
(
!
DDraw
7
)
{
trace
(
"Couldn't create DDraw interface, skipping tests
\n
"
);
return
;
}
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
hr
=
IDirectDraw7_QueryInterface
(
DDraw7
,
&
IID_IDirectDraw4
,
(
void
**
)
&
DDraw4
);
ok
(
hr
==
DD_OK
,
"IDirectDraw7_QueryInterface returned %08lx
\n
"
,
hr
);
hr
=
IDirectDraw7_QueryInterface
(
DDraw7
,
&
IID_IDirectDraw2
,
(
void
**
)
&
DDraw2
);
ok
(
hr
==
DD_OK
,
"IDirectDraw7_QueryInterface returned %08lx
\n
"
,
hr
);
hr
=
IDirectDraw7_QueryInterface
(
DDraw7
,
&
IID_IDirectDraw
,
(
void
**
)
&
DDraw1
);
ok
(
hr
==
DD_OK
,
"IDirectDraw7_QueryInterface returned %08lx
\n
"
,
hr
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw7
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
/* Fails without a cooplevel */
hr
=
IDirectDraw7_CreatePalette
(
DDraw
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
hr
=
IDirectDraw7_CreatePalette
(
DDraw
7
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
ok
(
hr
==
DDERR_NOCOOPERATIVELEVELSET
,
"CreatePalette returned %08lx
\n
"
,
hr
);
/* This check is before the cooplevel check */
hr
=
IDirectDraw7_CreatePalette
(
DDraw
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
(
void
*
)
0xdeadbeef
);
hr
=
IDirectDraw7_CreatePalette
(
DDraw
7
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
(
void
*
)
0xdeadbeef
);
ok
(
hr
==
CLASS_E_NOAGGREGATION
,
"CreatePalette returned %08lx
\n
"
,
hr
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
DDraw
,
0
,
DDSCL_NORMAL
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
DDraw
7
,
0
,
DDSCL_NORMAL
);
ok
(
hr
==
DD_OK
,
"SetCooperativeLevel failed with %08lx
\n
"
,
hr
);
memset
(
&
ddsd
,
0
,
sizeof
(
ddsd
));
...
...
@@ -85,22 +95,22 @@ static void test_ddraw_objects(void)
U4
(
ddsd
).
ddpfPixelFormat
.
dwFlags
=
DDPF_PALETTEINDEXED8
|
DDPF_RGB
;
U1
(
U4
(
ddsd
).
ddpfPixelFormat
).
dwRGBBitCount
=
8
;
hr
=
IDirectDraw7_CreateSurface
(
DDraw
,
&
ddsd
,
&
surface
,
NULL
);
hr
=
IDirectDraw7_CreateSurface
(
DDraw
7
,
&
ddsd
,
&
surface
,
NULL
);
ok
(
hr
==
DD_OK
,
"CreateSurface failed with %08lx
\n
"
,
hr
);
/* DDraw refcount increased by 1 */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
7
);
ok
(
ref
==
2
,
"Got refcount %ld, expected 2
\n
"
,
ref
);
/* Surface refcount starts with 1 */
ref
=
getRefcount
(
(
IUnknown
*
)
surface
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
hr
=
IDirectDraw7_CreatePalette
(
DDraw
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
hr
=
IDirectDraw7_CreatePalette
(
DDraw
7
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
ok
(
hr
==
DD_OK
,
"CreatePalette returned %08lx
\n
"
,
hr
);
/* DDraw refcount increased by 1 */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
7
);
ok
(
ref
==
3
,
"Got refcount %ld, expected 3
\n
"
,
ref
);
/* Palette starts with 1 */
...
...
@@ -119,7 +129,7 @@ static void test_ddraw_objects(void)
IDirectDrawSurface7_Release
(
surface
);
/* Incresed before - decrease now */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
7
);
ok
(
ref
==
2
,
"Got refcount %ld, expected 2
\n
"
,
ref
);
/* Releasing the surface detaches the palette */
...
...
@@ -129,10 +139,34 @@ static void test_ddraw_objects(void)
IDirectDrawPalette_Release
(
palette
);
/* Incresed before - decrease now */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
7
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
IDirectDraw7_Release
(
DDraw
);
/* Not all interfaces are AddRefed when a palette is created */
hr
=
IDirectDraw4_CreatePalette
(
DDraw4
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
ok
(
hr
==
DD_OK
,
"CreatePalette returned %08lx
\n
"
,
hr
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw4
);
ok
(
ref
==
2
,
"Got refcount %ld, expected 2
\n
"
,
ref
);
IDirectDrawPalette_Release
(
palette
);
/* No addref here */
hr
=
IDirectDraw2_CreatePalette
(
DDraw2
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
ok
(
hr
==
DD_OK
,
"CreatePalette returned %08lx
\n
"
,
hr
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw2
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
IDirectDrawPalette_Release
(
palette
);
/* No addref here */
hr
=
IDirectDraw_CreatePalette
(
DDraw1
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
ok
(
hr
==
DD_OK
,
"CreatePalette returned %08lx
\n
"
,
hr
);
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw1
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
IDirectDrawPalette_Release
(
palette
);
IDirectDraw7_Release
(
DDraw7
);
IDirectDraw4_Release
(
DDraw4
);
IDirectDraw2_Release
(
DDraw2
);
IDirectDraw_Release
(
DDraw1
);
}
static
void
test_iface_refcnt
(
void
)
...
...
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