PtColorWell change color callback not working

Hi everyone, please help me.

I have written an example with PtColorWell widget on PhAB, QNX 6.3.3.
I used a PtColorWell widget to change color of a PtRect, so I write a callback with event Pt_CS_COLOR_CHANGED, its name ColorChange() as below.

PgColor_t *mau; int ColorChange( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) { widget = widget, apinfo = apinfo, cbinfo = cbinfo; PtGetResource( widget, Pt_ARG_CS_COLOR, &mau, 0 ); return( Pt_CONTINUE ); }

But when I changed the PtColorWell, the variable mau had not changed. :frowning:( Can someone fix it for me? pls.

I found your problem.

In PtTimer_activate change the line listed below:

PtSetResource( ABW_PtRect1, Pt_ARG_FILL_COLOR, mau, 0);

to

PtSetResource( ABW_PtRect1, Pt_ARG_FILL_COLOR, *mau, 0);

yes, thank for your reply, maschoen :bulb: . I will try.

Hi maschoen, I have changed my code as you said, but it caused a SIGSEGV signal on that code line.

This happends on any codes with variable *mau, evently in debugging with printf() function.

 printf("%ld", *mau); 

…Is something wrong?

Hi, I found the problem! It has come from the PtGetResource() function.

I must using this function below to get CHANGED COLOR:

PgColor_t getcolor( PtWidget_t *widget, long type)
{
   PtArg_t arg;
   PtSetArg( &arg, type, 0, 0);
   PtGetResources( widget,1,&arg );
   return (PgColor_t) arg.value;
}

And calling it in the PtColorWell 's callback function:

int ColorChange( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
   mau= getcolor( widget, Pt_ARG_CS_COLOR );    
   // get the changed color to the variable mau

   PtSetResource( ABW_PtRect1, Pt_ARG_FILL_COLOR, mau, 0);
   // set this color to anothe widget
}

Thanks all :mrgreen: :mrgreen:

Hi maschoen, I have changed my code as you said, but it caused a SIGSEGV signal on that code line.

This happends on any codes with variable *mau, evently in debugging with printf() function.

 printf("%ld", *mau); 

…Is something wrong?
[/quote]
I forgot to mention. I initialized mau when I first saw the SIGSEGV. Actually, the way you are doing things is rather strange. You update the color picker and the rectangle colors asynchronously. You update the rectangle in a timer widget call. This is strange and unnecessary. At the very least you should keep the color in a global variable instead of mau. But I would update the rectangle when the color picker call is completed. That’s the obvious solution.

Thank you for your interest. The PtTimer I used as an example when looking for a solution to PtColorWell only.
I also found and corrected errors in the PtColorWell color change callback as above post.