ApGetWidgetPtr() bug report

Is ApGetWidgetPtr() function available ( working fine ) for widgets in
PtPane?

Problem:
In my application there’re 2 panes with optional picture modules so I
cannot use ABW_* manifest. I decided to use ApGetWidgetPtr() function to
access widgets in single pane. I’ve created PtPane widget, change pane
button and exit button in base window, 3 PtLabel widgets in picture module.

Callback for inserting picture module into pane was easy:

PtClearWidget( ABW_pane1 );
ApCreateModule( ABW_pane1, ABM_pict1, cbinfo );
PteRealizeWidget( ABW_pane1 );

And this is my setup function:

int
setup_pane1( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )
{

w = ApGetWidgetPtr( link_instance, ABW_string1 );
PtSetArg( w, Pt_ARG_FILL_COLOR, Pg_RED, 0 );
PtSetResources( w, 1, args );

}

And here problem arised. When ABN_ of widget was equal to ABN_ of pane,
fill color had changed for pane1 and not for widget! Changing fill color for
remaining widgets in picture module was without problem. When I changed
widget ordering in base window, problem had appeared with relevant widget in
pane. By using ABW_ manifest I accessed to the right widget.
This problem is very easy to reproduse… One base window, one picture
module and setup function for this module.

Can anybody help me? I need to use function ApGetWidgetPtr(), but this
technique doesn’t work. ( I don’t want to save ABW_ for each pane )

Unfortunately, the function works the way you described in Photon 1.xx.
It’s a limitation caused by the fact that the ABN numbers are only
unique within a module.

In Photon 2 (a.k.a. QNX 6) the ABN numbers are really unique and
ApGetWidgetPtr() works the way you expected it to work.

Martin Michalek <michalek@procaut.sk> wrote:

Is ApGetWidgetPtr() function available ( working fine ) for widgets in
PtPane?

Problem:
In my application there’re 2 panes with optional picture modules so I
cannot use ABW_* manifest. I decided to use ApGetWidgetPtr() function to
access widgets in single pane. I’ve created PtPane widget, change pane
button and exit button in base window, 3 PtLabel widgets in picture module.

Callback for inserting picture module into pane was easy:

PtClearWidget( ABW_pane1 );
ApCreateModule( ABW_pane1, ABM_pict1, cbinfo );
PteRealizeWidget( ABW_pane1 );

And this is my setup function:

int
setup_pane1( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )
{

w = ApGetWidgetPtr( link_instance, ABW_string1 );
PtSetArg( w, Pt_ARG_FILL_COLOR, Pg_RED, 0 );
PtSetResources( w, 1, args );

}

And here problem arised. When ABN_ of widget was equal to ABN_ of pane,
fill color had changed for pane1 and not for widget! Changing fill color for
remaining widgets in picture module was without problem. When I changed
widget ordering in base window, problem had appeared with relevant widget in
pane. By using ABW_ manifest I accessed to the right widget.
This problem is very easy to reproduse… One base window, one picture
module and setup function for this module.

Can anybody help me? I need to use function ApGetWidgetPtr(), but this
technique doesn’t work. ( I don’t want to save ABW_ for each pane )


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Wojtek Lerch <wojtek@qnx.com> wrote in message
news:9fip0r$hch$1@nntp.qnx.com

Unfortunately, the function works the way you described in Photon 1.xx.
It’s a limitation caused by the fact that the ABN numbers are only
unique within a module.

Window modules also allow you to have multiple widget’s instances.
ApGetWidgetPtr() funtions correctly with multiple window modules and ABN
number are identical within 2 or more windows. Also in pane ( picture
module ) I can use this funtion for all widgets except one… This is very
specific limitation :wink: … feature… :slight_smile:


So you advice me not to use fn ApGetWidgetPtr() at all?

( in application with pane widgets… )

Thanks for answer.

PS: Behaviour for getting widget ptr with ApGetWidgetPtr in pane changed in
ph1.14. Previously I got widget ptr outside from pane…

Martin Michalek <michalek@procaut.sk> wrote:

Wojtek Lerch <> wojtek@qnx.com> > wrote in message
news:9fip0r$hch$> 1@nntp.qnx.com> …
Unfortunately, the function works the way you described in Photon 1.xx.
It’s a limitation caused by the fact that the ABN numbers are only
unique within a module.

Window modules also allow you to have multiple widget’s instances.
ApGetWidgetPtr() funtions correctly with multiple window modules and ABN
number are identical within 2 or more windows. Also in pane ( picture
module ) I can use this funtion for all widgets except one… This is very
specific limitation > :wink: > … feature… > :slight_smile:

Trust me, it’s not specific to just that single widget.

If you have two widgets with the same ABN number in the same window,
ApGetWidgetPtr() will return one of them; but don’t ask me which one.
If it happened to be the one you expected most of the time, you have
just been lucky – but I don’t recommend relying on it.


So you advice me not to use fn ApGetWidgetPtr() at all?

( in application with pane widgets… )

This has nothing to do with pane widgets. The limitation only affects
modules that you have added widgets to, and only if you used
ApCreateModule() to add widgets. If you have a module that you haven’t
added any new widgets to, or if you have added some widgets to it using
PtCreateWidget(), ApCreateWidget(), or ApCreateWidgetFamily(),
ApGetWidgetPtr() should work just fine (but don’t use it to look for any
of the added widgets – it won’t find them).

Thanks for answer.

PS: Behaviour for getting widget ptr with ApGetWidgetPtr in pane changed in
ph1.14. Previously I got widget ptr outside from pane…

I don’t think ApGetWidgetPtr() has changed since Photon 1.0. But it is
possible that the behaviour you’re seeing changed when you re-generated
your app under 1.14 – PhAB might have renumbered the ABN numbers in
your modules.


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.