mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed crash due to setting clipper on uninitialized palette converter
This commit is contained in:
parent
607eb5e25b
commit
9aa22534ab
@ -9,6 +9,7 @@
|
||||
#include "CompatGdiPaintHandlers.h"
|
||||
#include "CompatGdiScrollFunctions.h"
|
||||
#include "CompatGdiWinProc.h"
|
||||
#include "CompatPaletteConverter.h"
|
||||
#include "CompatPrimarySurface.h"
|
||||
#include "DDrawProcs.h"
|
||||
#include "RealPrimarySurface.h"
|
||||
@ -231,6 +232,7 @@ namespace CompatGdi
|
||||
void installHooks()
|
||||
{
|
||||
InitializeCriticalSection(&g_gdiCriticalSection);
|
||||
CompatPaletteConverter::init();
|
||||
if (CompatGdiDcCache::init())
|
||||
{
|
||||
g_ddUnlockBeginEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
@ -87,7 +87,7 @@ namespace
|
||||
|
||||
namespace CompatPaletteConverter
|
||||
{
|
||||
bool init()
|
||||
bool create()
|
||||
{
|
||||
if (CompatPrimarySurface::displayMode.pixelFormat.dwRGBBitCount > 8 &&
|
||||
RealPrimarySurface::s_surfaceDesc.ddpfPixelFormat.dwRGBBitCount > 8)
|
||||
@ -95,14 +95,6 @@ namespace CompatPaletteConverter
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool isFirstInit = true;
|
||||
if (isFirstInit)
|
||||
{
|
||||
InitializeCriticalSection(&g_criticalSection);
|
||||
initHalftonePalette();
|
||||
isFirstInit = false;
|
||||
}
|
||||
|
||||
void* bits = nullptr;
|
||||
HBITMAP dib = createDibSection(bits);
|
||||
if (!dib)
|
||||
@ -136,6 +128,12 @@ namespace CompatPaletteConverter
|
||||
return true;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
InitializeCriticalSection(&g_criticalSection);
|
||||
initHalftonePalette();
|
||||
}
|
||||
|
||||
HDC lockDc()
|
||||
{
|
||||
EnterCriticalSection(&g_criticalSection);
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
namespace CompatPaletteConverter
|
||||
{
|
||||
bool init();
|
||||
bool create();
|
||||
void init();
|
||||
HDC lockDc();
|
||||
IDirectDrawSurface7* lockSurface();
|
||||
void release();
|
||||
|
@ -187,7 +187,7 @@ HRESULT RealPrimarySurface::create(DirectDraw& dd)
|
||||
s_surfaceDesc.dwSize = sizeof(s_surfaceDesc);
|
||||
g_frontBuffer->lpVtbl->GetSurfaceDesc(g_frontBuffer, &s_surfaceDesc);
|
||||
|
||||
if (!CompatPaletteConverter::init())
|
||||
if (!CompatPaletteConverter::create())
|
||||
{
|
||||
g_frontBuffer->lpVtbl->Release(g_frontBuffer);
|
||||
g_frontBuffer = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user