bug in context system ?
Tom?? Stan?k <[email protected]>
| Newsgroups | gmane.comp.video.picogui.devel |
|---|---|
| Message-ID | <[email protected]> |
hi it seems, that context system won't delete (or perhaps any way work with(setcontext, etc.))(?) widgets in context higher than 127. this state can be easily achieved becouse: ctx = pgEnterContext(); pgDeleteHandleContext(ctx); pgEnterContext() == ctx+1 (is it bug, or there cannot be more than 127 contexts ?) attaching testcase app.
context.c
(text/x-csrc, 1.5 KB)
#include <picogui.h>
#include <stdio.h>
pghandle left, right, main_w;
pghandle ctx;
int add(struct pgEvent *evt){
pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, left);
pgSetWidget(PGDEFAULT, PG_WP_TEXT, pgNewString("x"), 0);
return 0;
}
int rm(struct pgEvent *evt){
printf("deleting: %ld\n",ctx);
pgDeleteHandleContext(ctx);
//pgLeaveContext();
ctx = pgEnterContext();
printf("entered: %ld\n",ctx);
return 0;
}
int update(struct pgEvent *evt){
pgUpdate();
return 0;
}
int main(){
int i;
pgInit(0, NULL);
pgRegisterApp(PG_APP_NORMAL, NULL, 0);
main_w = pgNewWidget(PG_WIDGET_BOX, 0, 0);
left = pgNewWidget(PG_WIDGET_LABEL, PG_DERIVE_INSIDE, main_w);
pgSetWidget(PGDEFAULT, PG_WP_SIDE, PG_S_LEFT, 0);
right = pgNewWidget(PG_WIDGET_LABEL, PG_DERIVE_INSIDE, main_w);
pgSetWidget(PGDEFAULT, PG_WP_SIDE, PG_S_RIGHT, 0);
pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, right);
pgSetWidget(PGDEFAULT, PG_WP_TEXT, pgNewString("add button"), 0);
pgBind(PGDEFAULT, PGBIND_ANY, add, NULL);
pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, right);
pgSetWidget(PGDEFAULT, PG_WP_TEXT, pgNewString("rm context"), 0);
pgBind(PGDEFAULT, PGBIND_ANY, rm, NULL);
pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, right);
pgSetWidget(PGDEFAULT, PG_WP_TEXT, pgNewString("update"), 0);
pgBind(PGDEFAULT, PGBIND_ANY, update, NULL);
pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, right);
pgSetWidget(PGDEFAULT, PG_WP_TEXT, pgNewString("dummy"), 0);
pgUpdate();
ctx = pgEnterContext();
for (i=0; i<125; i++) rm(NULL);
pgEventLoop();
return 0;
}