Fix acquiring HDC from wxGCDC with non-GDI+ graphics context
HDC can be acquired/released only when wxGCDC is associated with GDI+ graphics context. Closes #19207.
This commit is contained in:
@@ -306,6 +306,9 @@ public:
|
||||
it changes them, so it is safe to assume that the same pen, brush and colours
|
||||
that were active before the call to this function are still in effect after it.
|
||||
|
||||
@note Under wxMSW drawing on wxGCDC is possible only if it's associated with
|
||||
GDI+ wxGraphicsContext.
|
||||
|
||||
@library{wxcore}
|
||||
@category{gdi}
|
||||
*/
|
||||
|
@@ -3013,13 +3013,9 @@ WXHDC wxGCDC::AcquireHDC()
|
||||
if ( !gc )
|
||||
return NULL;
|
||||
|
||||
#if wxUSE_CAIRO
|
||||
// we can't get the HDC if it is not a GDI+ context
|
||||
wxGraphicsRenderer* r1 = gc->GetRenderer();
|
||||
wxGraphicsRenderer* r2 = wxGraphicsRenderer::GetCairoRenderer();
|
||||
if (r1 == r2)
|
||||
return NULL;
|
||||
#endif
|
||||
wxCHECK_MSG(gc->GetRenderer() == wxGraphicsRenderer::GetGDIPlusRenderer(), NULL,
|
||||
"can't get HDC because this is not GDI+ context");
|
||||
|
||||
Graphics * const g = static_cast<Graphics *>(gc->GetNativeContext());
|
||||
return g ? g->GetHDC() : NULL;
|
||||
@@ -3033,13 +3029,8 @@ void wxGCDC::ReleaseHDC(WXHDC hdc)
|
||||
wxGraphicsContext * const gc = GetGraphicsContext();
|
||||
wxCHECK_RET( gc, "can't release HDC because there is no wxGraphicsContext" );
|
||||
|
||||
#if wxUSE_CAIRO
|
||||
// we can't get the HDC if it is not a GDI+ context
|
||||
wxGraphicsRenderer* r1 = gc->GetRenderer();
|
||||
wxGraphicsRenderer* r2 = wxGraphicsRenderer::GetCairoRenderer();
|
||||
if (r1 == r2)
|
||||
return;
|
||||
#endif
|
||||
wxCHECK_RET(gc->GetRenderer() == wxGraphicsRenderer::GetGDIPlusRenderer(),
|
||||
"can't release HDC because this is not GDI+ context");
|
||||
|
||||
Graphics * const g = static_cast<Graphics *>(gc->GetNativeContext());
|
||||
wxCHECK_RET( g, "can't release HDC because there is no Graphics" );
|
||||
|
Reference in New Issue
Block a user