Hi,
i have a problem using the method PtSendEventToWidget. It seems to be a memory violation access problem. In fact, to be able to call this method without having a crash due to memory violation, we have to declare previously an unused char variable. It seems that this memory offset is necessary; but why ?!
Here is the part of the code in which the problem is met:
int testCallbackButton(PtWidget_t *w, void *data,PtCallbackInfo_t *cbinfo)
{
/*
* Here is the mysterious line !
* If we remove it, it doesn't work, it crashes
* on the PtSendEventToWidget call
*/
char a; //This is a necessary unused variable
struct{
PhEvent_t event;
PhRect_t rect;
PhPointerEvent_t pevent;
} new_event;
memset(&new_event.rect,-1,sizeof(new_event.rect));
new_event.event.processing_flags = 0;
new_event.event.type = Ph_EV_BUT_PRESS;
new_event.pevent.click_count = 1;
new_event.pevent.buttons = Ph_BUTTON_SELECT;
new_event.event.num_rects = 1;
printf("%s %d\n",__FILE__,__LINE__);
PtSendEventToWidget(button1,(PhEvent_t *) &new_event);
printf("%s %d\n",__FILE__,__LINE__);
}
In the code above, if we remove the declaration of the unused variable a, then we have a crash when PtSendEventToWidget is called.
Thanks for your help