Skip to content

Commit

Permalink
修复内存泄漏
Browse files Browse the repository at this point in the history
  • Loading branch information
zero-rp committed Feb 23, 2017
1 parent 8b7fc5a commit 6390b4d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ZUI/core/control.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <ZUI.h>

extern rb_root *Global_ControlClass;
ZuiVoid ZuiFreeAttributeCallBack(void *data) {
ZuiAttribute att = data;
if (att->type == ZAttType_String) {
ZuiFree(att->v);
}
ZuiFree(att);
}
//创建控件
ZuiControl NewZuiControl(ZuiText classname, ZuiAny Param1, ZuiAny Param2, ZuiAny Param3) {
ZuiControl p = (ZuiControl)ZuiMalloc(sizeof(ZControl));
Expand Down Expand Up @@ -487,6 +494,8 @@ ZEXPORT ZuiAny ZCALL ZuiDefaultControlProc(ZuiInt ProcId, ZuiControl p, ZuiAny U
case Proc_OnDestroy: {
if (p->m_sText)
ZuiFree(p->m_sText);
if (p->m_sName)
ZuiFree(p->m_sName);
if (p->m_sToolTip)
ZuiFree(p->m_sToolTip);
if (p->m_BkgImg)
Expand All @@ -495,6 +504,8 @@ ZEXPORT ZuiAny ZCALL ZuiDefaultControlProc(ZuiInt ProcId, ZuiControl p, ZuiAny U
ZuiControlCall(Proc_Layout_Remove, p->m_pParent, p, TRUE, NULL);
if (p->m_pManager != NULL)
ZuiPaintManagerReapObjects(p->m_pManager, p);
rb_foreach(p->m_rAttribute, ZuiFreeAttributeCallBack);
rb_free(p->m_rAttribute);
#if RUN_DEBUG
ZuiFree(p->m_sClassName);
#endif // RUN_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion ZUI/core/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ ZuiVoid ZuiStartDebug() {

HWND htabctrl = GetDlgItem(hwnd, IDC_TAB1);
TCITEM tie;//设置tab标签的属性
LPWSTR tabname[4] = { L"内存跟踪",L"资源管理",L"控件Spy",L"脚本调试" };
LPWSTR tabname[5] = { L"内存跟踪",L"资源管理",L"控件Spy",L"脚本调试",L"日志" };
tie.mask = TCIF_TEXT | TCIF_IMAGE;//psztext字段有效
tie.iImage = -1;
for (INT i = 0; i < 3; i++)
Expand Down
3 changes: 3 additions & 0 deletions ZUI/layout/HorizontalLayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ void* CALLBACK ZuiHorizontalLayoutProc(int ProcId, ZuiControl cp, ZuiHorizontalL

break;
}
case Proc_CoreUnInit: {
return NULL;
}
default:
break;
}
Expand Down

0 comments on commit 6390b4d

Please sign in to comment.