Print Page | Close Window

BUG: Invalid assert in CXTPFontDC of v19.3

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=24170
Printed Date: 22 December 2024 at 1:34pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: BUG: Invalid assert in CXTPFontDC of v19.3
Posted By: mgampi
Subject: BUG: Invalid assert in CXTPFontDC of v19.3
Date Posted: 15 June 2021 at 7:50am
Hi;

I believe that the selected VERIFY() statement is wrong. I use the CXTPRichRender to render a RTF text with a preselected font and therefore the condition is NEVER met - it can't:

void CXTPFontDC::ReleaseFont()
{
    if (NULL != m_pOldFont)
    {
#ifdef _DEBUG
        if (NULL != m_pCurrentFont)
        {
            VERIFY((m_pDC->SelectObject(m_pOldFont)->GetSafeHandle()
                    == m_pCurrentFont->GetSafeHandle()
)
                   && "Potential GDI leak detected: Another font has been selected to the memory "
                      "DC and not released.");
        }
        else
        {
            m_pDC->SelectObject(m_pOldFont);
        }
#else
        m_pDC->SelectObject(m_pOldFont);
#endif

        m_pOldFont     = NULL;
        m_pCurrentFont = NULL;
    }
}

I use this code (simplified) to render the text and as you see I never assign another font:
CXTPClientRect rc(this);
CXTPBufferDC memDC(dc, rc);

DrawBackground(&memDC, &m_toolVisible, rc);

COLORREF clrTextColor = m_pContext->GetTipTextColor();
memDC.SetBkMode(TRANSPARENT);
memDC.SetTextColor(clrTextColor);
CXTPFontDC font(&memDC, _pMyContext->GetFont());
   
rc.DeflateRect(m_pContext->GetMargin());
rc.DeflateRect(3, 3, 3, 3);
m_render.DrawText(pDC, rc);
font.ReleaseFont();  <-- Here above VERIFY fails

CWnd::DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);

Can I safely remove the VERIFY()?


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



Replies:
Posted By: astoyan
Date Posted: 15 June 2021 at 5:56pm
Hi, that's the leak in rich edit itself and we're aware of it. You don't need to remove anything, add font.DisableHandleLeakDetection() right after declaring the font variable, it should do the trick.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net