fix memory unsafe
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@392 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
791960a128
commit
ec86f5297e
1 changed files with 10 additions and 11 deletions
19
src/core.c
19
src/core.c
|
|
@ -171,6 +171,7 @@ MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget p
|
||||||
|
|
||||||
static void MwFreeWidget(MwWidget handle) {
|
static void MwFreeWidget(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
|
MwWidget root = handle;
|
||||||
|
|
||||||
MwDispatch(handle, destroy);
|
MwDispatch(handle, destroy);
|
||||||
|
|
||||||
|
|
@ -178,6 +179,14 @@ static void MwFreeWidget(MwWidget handle) {
|
||||||
MwFreeWidget(handle->children[i]);
|
MwFreeWidget(handle->children[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(root->parent != NULL) root = root->parent;
|
||||||
|
for(i = 0; i < arrlen(root->tick_list); i++) {
|
||||||
|
if(handle == root->tick_list[i]) {
|
||||||
|
arrdel(root->tick_list, i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(handle->name);
|
free(handle->name);
|
||||||
|
|
||||||
MwLLDestroy(handle->lowlevel);
|
MwLLDestroy(handle->lowlevel);
|
||||||
|
|
@ -199,19 +208,9 @@ static void MwFreeWidget(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDestroyWidget(MwWidget handle) {
|
void MwDestroyWidget(MwWidget handle) {
|
||||||
int i;
|
|
||||||
MwWidget root = handle;
|
|
||||||
if(handle->parent != NULL) {
|
if(handle->parent != NULL) {
|
||||||
arrput(handle->parent->destroy_queue, handle);
|
arrput(handle->parent->destroy_queue, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(root->parent != NULL) root = root->parent;
|
|
||||||
for(i = 0; i < arrlen(root->tick_list); i++) {
|
|
||||||
if(handle == root->tick_list[i]) {
|
|
||||||
arrdel(root->tick_list, i);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwStep(MwWidget handle) {
|
void MwStep(MwWidget handle) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue