Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - PtSetResource -> PtImmortalizeWidget: (6 Items)
   
PtSetResource -> PtImmortalizeWidget  
Hi,

I try to set the text from a normal application to a photon label in a photon window. I can see the label and other 
textfields, when I start the photon application. Input_proc is a message handler, which receives the messages from my 
normal application. I use a message channel with name_attach. This works, at least the "OK!" string is returned and 
print out by the normal application. The printf "Photon input .... Is not shown. When I try to change the text (msg 
receive) within a label or textfield, I get a memory violation from PtImmortalizeWidget. I have no idea what this means 
and how to get it running. Can someone help me with that?



 Sourcecode from abmain.c (exe=lcdPhoton)
70 int input_proc(void *client_data, pid_t pid, void *msg,
 71                size_t msglen)
 72 {
 73
 74     struct MyMsg* mymsg = (struct MyMsg *) msg;
 75
 76     printf("Photon input message called");
 77
 78     MsgReply(pid,0, "OK!", 4);
 79 //  PtHold();
 80     //  PtSetResource(widget, type, value, len);
 81 //  PtTextModifyText(ABW_PtText1, 0,0 , -1, "wos is", 6);
 82     PtSetResource(ABW_PtLabel0, Pt_ARG_TEXT_STRING, "wos is" /* mymsg->data */, 0);
 83 //  PtRelease();
 84     PtFlush();
88  return Pt_CONTINUE;
 89 }




Command line output

1message send ok
2reply : OK!
3
4Process 294935 (lcdPhoton) terminated SIGSEGV code=1 fltno=11 ip=011db640(libph.
5so.3@PtImmortalizeWidget+0x0) mapaddr=000db640. ref=00000064


Chris
RE: PtSetResource -> PtImmortalizeWidget  
What application core faulted, the one with this input proc, or the one
that sent the message?  What does struct MyMsg look like?

-----Original Message-----
From: Christian Lechner [mailto:community-noreply@qnx.com] 
Sent: Thursday, June 24, 2010 5:17 AM
To: photon-graphics
Subject: PtSetResource -> PtImmortalizeWidget

Hi,

I try to set the text from a normal application to a photon label in a
photon window. I can see the label and other textfields, when I start
the photon application. Input_proc is a message handler, which receives
the messages from my normal application. I use a message channel with
name_attach. This works, at least the "OK!" string is returned and print
out by the normal application. The printf "Photon input .... Is not
shown. When I try to change the text (msg receive) within a label or
textfield, I get a memory violation from PtImmortalizeWidget. I have no
idea what this means and how to get it running. Can someone help me with
that?



 Sourcecode from abmain.c (exe=lcdPhoton)
70 int input_proc(void *client_data, pid_t pid, void *msg,
 71                size_t msglen)
 72 {
 73
 74     struct MyMsg* mymsg = (struct MyMsg *) msg;
 75
 76     printf("Photon input message called");
 77
 78     MsgReply(pid,0, "OK!", 4);
 79 //  PtHold();
 80     //  PtSetResource(widget, type, value, len);
 81 //  PtTextModifyText(ABW_PtText1, 0,0 , -1, "wos is", 6);
 82     PtSetResource(ABW_PtLabel0, Pt_ARG_TEXT_STRING, "wos is" /*
mymsg->data */, 0);
 83 //  PtRelease();
 84     PtFlush();
88  return Pt_CONTINUE;
 89 }




Command line output

1message send ok
2reply : OK!
3
4Process 294935 (lcdPhoton) terminated SIGSEGV code=1 fltno=11
ip=011db640(libph.
5so.3@PtImmortalizeWidget+0x0) mapaddr=000db640. ref=00000064


Chris




_______________________________________________

Photon microGUI
http://community.qnx.com/sf/go/post57756
Re: RE: PtSetResource -> PtImmortalizeWidget  
HI,

struct MyMsg {
        char data[20];
};


I don't think it's because of the message. Right now, I just use the message to call the input_proc. The photon 
application lcdPhoton with the input_proc crashes. When I comment PtSetResource from this function, everything works 
fine. (except printf("Photon ....)

Well, something is wront with my widget pointer I think. I found the code for PtSetResource

int PtSetResources( PtWidget_t *widget, int n_args, PtArg_t const *args )
 58 {
 59         int ret;
 60     PtHold();
 61     PtImmortalizeWidget( widget );
 62     ret = (*widget->class_rec->setres_f)( widget, n_args, args, NULL );
 63     if ((widget->flags & (Pt_REALIZED|Pt_REALIZING))||(widget->class_rec->flags & Pt_FORCE_SYNC))
 64         PtSyncWidget( widget );
 65     PtMortalizeWidget( widget );
 66     PtRelease();
 67     return( ret );
 68 }

/*
 80  * Set only one widget resource (no PtSetArg needed to use this)
 81  */
 82 int _PtSetResource( PtWidget_t *widget,long type,long value,long len)
 83 {
 84     PtArg_t arg = { type, value, len };
 85     return PtSetResources( widget, 1, &arg );
 86 }

void PtImmortalizeWidget( PtWidget_t *widget ) {
282     while   (   ++widget->is_immortal == 1
283             &&  ( widget = widget->parent ) != NULL
284                 );
285     }

:#define ABW_PtText0                          AbGetABW( ABN_PtText0 )
9:#define ABW_PtText1                          AbGetABW( ABN_PtText1 )
11:#define ABW_PtLabel0                         AbGetABW( ABN_PtLabel0 )

But e.g. ABN_PtText0 is defined (from PhAB) and the AbGetABW() function should return a Pt_Widget_t *. 
But the runtime has some problem with the pointer.

Maybe someone has an answer, why printf doesn't work. It would be helpful to see some values.


Chris
RE: RE: PtSetResource -> PtImmortalizeWidget  
try a flushall() after the printf, see if that helps ...

-----Original Message-----
From: Christian Lechner [mailto:community-noreply@qnx.com] 
Sent: Thursday, June 24, 2010 9:49 AM
To: photon-graphics
Subject: Re: RE: PtSetResource -> PtImmortalizeWidget

HI,

struct MyMsg {
        char data[20];
};


I don't think it's because of the message. Right now, I just use the
message to call the input_proc. The photon application lcdPhoton with
the input_proc crashes. When I comment PtSetResource from this function,
everything works fine. (except printf("Photon ....)

Well, something is wront with my widget pointer I think. I found the
code for PtSetResource

int PtSetResources( PtWidget_t *widget, int n_args, PtArg_t const *args
)
 58 {
 59         int ret;
 60     PtHold();
 61     PtImmortalizeWidget( widget );
 62     ret = (*widget->class_rec->setres_f)( widget, n_args, args, NULL
);
 63     if ((widget->flags &
(Pt_REALIZED|Pt_REALIZING))||(widget->class_rec->flags & Pt_FORCE_SYNC))
 64         PtSyncWidget( widget );
 65     PtMortalizeWidget( widget );
 66     PtRelease();
 67     return( ret );
 68 }

/*
 80  * Set only one widget resource (no PtSetArg needed to use this)
 81  */
 82 int _PtSetResource( PtWidget_t *widget,long type,long value,long
len)
 83 {
 84     PtArg_t arg = { type, value, len };
 85     return PtSetResources( widget, 1, &arg );
 86 }

void PtImmortalizeWidget( PtWidget_t *widget ) {
282     while   (   ++widget->is_immortal == 1
283             &&  ( widget = widget->parent ) != NULL
284                 );
285     }

:#define ABW_PtText0                          AbGetABW( ABN_PtText0 )
9:#define ABW_PtText1                          AbGetABW( ABN_PtText1 )
11:#define ABW_PtLabel0                         AbGetABW( ABN_PtLabel0 )

But e.g. ABN_PtText0 is defined (from PhAB) and the AbGetABW() function
should return a Pt_Widget_t *. 
But the runtime has some problem with the pointer.

Maybe someone has an answer, why printf doesn't work. It would be
helpful to see some values.


Chris




_______________________________________________

Photon microGUI
http://community.qnx.com/sf/go/post57782
Re: RE: RE: PtSetResource -> PtImmortalizeWidget  
Hi,

thanks, flushall() worked. I get a 0 pointer for the Widget:

Photon input message called
ABN_PtText0 1, WidgetPtr 0 (<- printf("%X", AbGetABW(ABN_PtText0)))

Within the code I didn't find the line where AbWidgets[] is initialized.
Hence, I tried to make a new PhAB project with just one text field, and now it works. I don't know why, but somehow the 
generated PhAB files were corrupt.

Tanks again for helping

Chris
RE: RE: RE: PtSetResource -> PtImmortalizeWidget  
you're welcome.

-----Original Message-----
From: Christian Lechner [mailto:community-noreply@qnx.com] 
Sent: Thursday, June 24, 2010 10:44 AM
To: photon-graphics
Subject: Re: RE: RE: PtSetResource -> PtImmortalizeWidget

Hi,

thanks, flushall() worked. I get a 0 pointer for the Widget:

Photon input message called
ABN_PtText0 1, WidgetPtr 0 (<- printf("%X", AbGetABW(ABN_PtText0)))

Within the code I didn't find the line where AbWidgets[] is initialized.
Hence, I tried to make a new PhAB project with just one text field, and
now it works. I don't know why, but somehow the generated PhAB files
were corrupt.

Tanks again for helping

Chris



_______________________________________________

Photon microGUI
http://community.qnx.com/sf/go/post57793