ui/common/object.c

branch
newapi
changeset 383
03599608d555
parent 328
059cba080ab4
child 384
8be7fd628fbc
equal deleted inserted replaced
382:de653b07050b 383:03599608d555
47 // TODO: free last obj 47 // TODO: free last obj
48 prev->next = NULL; 48 prev->next = NULL;
49 } 49 }
50 } 50 }
51 51
52 void ui_object_ref(UiObject *obj) {
53 obj->ref++;
54 }
55
56 void ui_object_unref(UiObject *obj) {
57 if(--obj->ref == 0) {
58 if(obj->destroy) {
59 obj->destroy(obj);
60 } else {
61 uic_object_destroy(obj);
62 }
63 }
64 }
65
66 void uic_object_destroy(UiObject *obj) {
67 if(obj->ctx->close_callback) {
68 UiEvent ev;
69 ev.window = obj->window;
70 ev.document = obj->ctx->document;
71 ev.obj = obj;
72 ev.eventdata = NULL;
73 ev.intval = 0;
74 obj->ctx->close_callback(&ev, obj->ctx->close_data);
75 }
76 cxMempoolDestroy(obj->ctx->mp);
77 }
52 78
53 UiObject* uic_object_new(UiObject *toplevel, UIWIDGET widget) { 79 UiObject* uic_object_new(UiObject *toplevel, UIWIDGET widget) {
54 return uic_ctx_object_new(toplevel->ctx, widget); 80 return uic_ctx_object_new(toplevel->ctx, widget);
55 } 81 }
56 82

mercurial