introduce MwFreeWidget
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
3779b2e0db
commit
4bf321f3a2
6 changed files with 47 additions and 6 deletions
|
|
@ -375,6 +375,14 @@ MWDECL void MWAPI MwSetUser(MwWidget handle, void* user);
|
|||
*/
|
||||
MWDECL void* MWAPI MwGetUser(MwWidget handle);
|
||||
|
||||
/*!
|
||||
* @brief Free the widget
|
||||
* @param handle Widget
|
||||
* @warning This is used internally!
|
||||
* @note You can call this on toplevel widget safely if you're sure no event loops will be ran, e.g. after `MwLoop`.
|
||||
*/
|
||||
MWDECL void MWAPI MwFreeWidget(MwWidget handle);
|
||||
|
||||
#ifdef _MILSKO
|
||||
MWDECL void MwForceRender_Internal(MwWidget handle);
|
||||
MWDECL void MwForceRender2_Internal(MwWidget handle, void* ptr);
|
||||
|
|
|
|||
19
milsko.xml
19
milsko.xml
|
|
@ -518,6 +518,25 @@
|
|||
<widget name="handle" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="MwSetUser">
|
||||
<arguments>
|
||||
<widget name="handle" />
|
||||
<pointer name="user" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="MwGetUser">
|
||||
<return>
|
||||
<pointer />
|
||||
</return>
|
||||
<arguments>
|
||||
<widget name="handle" />
|
||||
</arguments>
|
||||
</function>
|
||||
<function name="MwFreeWidget">
|
||||
<arguments>
|
||||
<widget name="handle" />
|
||||
</arguments>
|
||||
</function>
|
||||
</functions>
|
||||
</header>
|
||||
<header name="Dialog/FileChooser">
|
||||
|
|
|
|||
|
|
@ -1164,6 +1164,9 @@ Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask) {
|
|||
XDestroyImage(cimage);
|
||||
XDestroyImage(cmask);
|
||||
|
||||
XFreeGC(display, imagegc);
|
||||
XFreeGC(display, maskgc);
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
|
|
|
|||
11
src/core.c
11
src/core.c
|
|
@ -278,8 +278,10 @@ static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name,
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
h->root_font = NULL;
|
||||
h->root_boldfont = NULL;
|
||||
h->root_font = NULL;
|
||||
h->root_boldfont = NULL;
|
||||
h->root_monofont = NULL;
|
||||
h->root_boldmonofont = NULL;
|
||||
}
|
||||
|
||||
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
||||
|
|
@ -324,7 +326,7 @@ MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget p
|
|||
return h;
|
||||
}
|
||||
|
||||
static void MwFreeWidget(MwWidget handle) {
|
||||
void MwFreeWidget(MwWidget handle) {
|
||||
int i;
|
||||
MwWidget root = handle;
|
||||
MwWidget w;
|
||||
|
|
@ -351,6 +353,7 @@ static void MwFreeWidget(MwWidget handle) {
|
|||
for(i = 0; i < arrlen(handle->children); i++) {
|
||||
MwFreeWidget(handle->children[i]);
|
||||
}
|
||||
arrfree(handle->children);
|
||||
|
||||
while(root->parent != NULL) root = root->parent;
|
||||
for(i = 0; i < arrlen(root->tick_list); i++) {
|
||||
|
|
@ -384,6 +387,8 @@ static void MwFreeWidget(MwWidget handle) {
|
|||
|
||||
if(handle->root_font != NULL) MwFontFree(handle->root_font);
|
||||
if(handle->root_boldfont != NULL) MwFontFree(handle->root_boldfont);
|
||||
if(handle->root_monofont != NULL) MwFontFree(handle->root_monofont);
|
||||
if(handle->root_boldmonofont != NULL) MwFontFree(handle->root_boldmonofont);
|
||||
|
||||
free(handle);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,6 +309,8 @@ static void draw(MwWidget handle) {
|
|||
r.width = w;
|
||||
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
||||
|
||||
free(raw);
|
||||
|
||||
MwLLDestroyPixmap(px);
|
||||
} else {
|
||||
r.width -= MwGetInteger(handle, MwNleftPadding);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ char* int_params[] = {/*MwNx, MwNy, MwNwidth, MwNheight,*/ MwNorientation,
|
|||
unsigned long maxxes[] = {UINT8_MAX, UINT16_MAX, UINT32_MAX, UINT64_MAX};
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
int i, j = 0;
|
||||
char input;
|
||||
MwWidget window, widget;
|
||||
unsigned long upper_limit;
|
||||
|
|
@ -49,14 +49,14 @@ get_input:
|
|||
|
||||
window = MwCreateWidget(MwWindowClass, "window", NULL, 0, 0, 400, 400);
|
||||
|
||||
while(MwPending(window)) {
|
||||
while(MwPending(window) && j < 50) {
|
||||
int class_num = rand() % (sizeof(classes) / sizeof(cls_pair_t));
|
||||
widget = MwCreateWidget(*classes[class_num].cls, classes[class_num].name, window, 0, 0, 100, 100);
|
||||
|
||||
printf("%s\n", classes[class_num].name);
|
||||
/* apply int params with random scale */
|
||||
for(i = 0; i < (sizeof(int_params) / sizeof(void*)); i++) {
|
||||
unsigned long number = rand() % UINT8_MAX;
|
||||
unsigned long number = rand() % upper_limit;
|
||||
printf("> %s = %lu\n", int_params[i], number);
|
||||
MwVaApply(widget, int_params[i], number, NULL);
|
||||
}
|
||||
|
|
@ -65,5 +65,9 @@ get_input:
|
|||
MwDestroyWidget(widget);
|
||||
|
||||
printf("\n");
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
MwFreeWidget(window);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue