Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - BUG: Invalid assert in CXTPFontDC of v19.3
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

BUG: Invalid assert in CXTPFontDC of v19.3

 Post Reply Post Reply
Author
Message
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: BUG: Invalid assert in CXTPFontDC of v19.3
    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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 284
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.