Skip navigation.
Home
The QNX Community Portal

View topic - PtColorWell change color callback not working

PtColorWell change color callback not working

Discussion about the general applications that run on QNX6

PtColorWell change color callback not working

Postby sieudot » Sat Jun 08, 2013 7:42 am

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.

Code: Select all
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. :(( Can someone fix it for me? pls.
Attachments
Colordemo.zip
p/s: Full AB project attached here:
(260.27 KiB) Downloaded 219 times
sieudot
Active Member
 
Posts: 45
Joined: Thu Mar 17, 2005 8:14 am
Location: VietNam

Re: PtColorWell change color callback not working

Postby maschoen » Sat Jun 08, 2013 6:59 pm

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);
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: PtColorWell change color callback not working

Postby sieudot » Sun Jun 09, 2013 8:54 am

yes, thank for your reply, maschoen :idea: . I will try.
sieudot
Active Member
 
Posts: 45
Joined: Thu Mar 17, 2005 8:14 am
Location: VietNam

Re: PtColorWell change color callback not working

Postby sieudot » Sun Jun 09, 2013 11:39 am

maschoen wrote: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);


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.

Code: Select all
 printf("%ld", *mau);


..Is something wrong?
sieudot
Active Member
 
Posts: 45
Joined: Thu Mar 17, 2005 8:14 am
Location: VietNam

Re: PtColorWell change color callback not working

Postby sieudot » Sun Jun 09, 2013 1:02 pm

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

I must using this function below to get CHANGED COLOR:

Code: Select all
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:
Code: Select all
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:
sieudot
Active Member
 
Posts: 45
Joined: Thu Mar 17, 2005 8:14 am
Location: VietNam

Re: PtColorWell change color callback not working

Postby maschoen » Sun Jun 09, 2013 6:56 pm

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.

Code: Select all
 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.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: PtColorWell change color callback not working

Postby sieudot » Mon Jun 10, 2013 2:55 am

maschoen wrote: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.
sieudot
Active Member
 
Posts: 45
Joined: Thu Mar 17, 2005 8:14 am
Location: VietNam


Return to QNX6 - Applications

Who is online

Users browsing this forum: No registered users and 2 guests