Skip to content

Commit

Permalink
修复:UIRing和UIGifAnim内存泄漏的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
qdtroy committed Dec 13, 2022
1 parent 8fbe3c3 commit 45e6c72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 7 additions & 3 deletions DuiLib/Control/UIGifAnim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace DuiLib
{
IMPLEMENT_DUICONTROL(CGifAnimUI)

CGifAnimUI::CGifAnimUI(void)
CGifAnimUI::CGifAnimUI(void)
{
m_pGifImage = NULL;
m_pPropertyItem = NULL;
Expand Down Expand Up @@ -161,10 +161,14 @@ namespace DuiLib
void CGifAnimUI::InitGifImage()
{
TImageInfo* pImageInfo = CRenderEngine::GdiplusLoadImage(GetBkImage());
if(pImageInfo == NULL) return;
if(pImageInfo != NULL) {
m_pGifImage = pImageInfo->pImage;

m_pGifImage = pImageInfo->pImage;
delete pImageInfo;
pImageInfo = NULL;
}
if ( NULL == m_pGifImage ) return;

UINT nCount = 0;
nCount = m_pGifImage->GetFrameDimensionsCount();
GUID* pDimensionIDs = new GUID[ nCount ];
Expand Down
18 changes: 12 additions & 6 deletions DuiLib/Control/UIRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace DuiLib
{
IMPLEMENT_DUICONTROL(CRingUI)

CRingUI::CRingUI() : m_fCurAngle(0.0f), m_pBkimage(NULL)
CRingUI::CRingUI() : m_fCurAngle(0.0f), m_pBkimage(NULL)
{
}

Expand Down Expand Up @@ -52,7 +52,7 @@ namespace DuiLib
int iWidth = rcItem.right - rcItem.left;
int iHeight = rcItem.bottom - rcItem.top;
Gdiplus::PointF centerPos(rcItem.left + iWidth/2, rcItem.top + iHeight/2);

// 解决偶数时抖动问题
if ((iWidth % 2) == 0) centerPos.X -= 0.5;
if ((iHeight % 2) == 0) centerPos.Y -= 0.5;
Expand Down Expand Up @@ -83,11 +83,17 @@ namespace DuiLib
void CRingUI::InitImage()
{
TImageInfo* pImageInfo = CRenderEngine::GdiplusLoadImage(GetBkImage());
if(pImageInfo == NULL) return;
if(pImageInfo != NULL) {
m_pBkimage = pImageInfo->pImage;

delete pImageInfo;
pImageInfo = NULL;

if(m_pManager != NULL && m_pBkimage != NULL) {
m_pManager->SetTimer(this, RING_TIMERID, 100);
}
}

m_pBkimage = pImageInfo->pImage;
if ( NULL == m_pBkimage ) return;
if(m_pManager) m_pManager->SetTimer(this, RING_TIMERID, 100);
}

void CRingUI::DeleteImage()
Expand Down

0 comments on commit 45e6c72

Please sign in to comment.