Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Timer widgets come back from the dead: (6 Items)
   
Timer widgets come back from the dead  
I am updating a QNX 4.25 application to work on 6.5.  It has a Photon GUI controlled with a keypad with the number 
digits and a few function keys.  The GUI consists of a base window with a pane.  This pane gets realized from a picture 
module in response to events triggered by the function keys (done with PtTab and PtGroup, not PtPanelGroup).

What I find happens is if I show a pane that contains a PtTimer or sometimes PtClock, then replace that pane with 
another:
 PtClearWidget(ABW_Pane);
 ApCreateModule(ABM_NewPane_Module, ABW_Pane, NULL);
 PtReRealizeWidget(ABW_Pane):

then although the PtTimer widget is unrealized, after the call to PtReRealizeWidget it has been re-realized even though 
it is not part of AMB_NewPane_Module.  I can put debug statements into Realized and UnRealized callbacks and see this 
happen.  The widget flags go from 0x1 to 0x1000 (Pt_REALIZED to Pt_DESTROYED), then 0x1000 to 0x1001 (destroyed and 
realized!).

When the PtTimer activate event happens, the event loop gets horribly confused looking up the callback function.  I 
either get a SIGSEGV in in the Photon library or it spins madly in the event handling code.

What is going wrong?
RE: Timer widgets come back from the dead  
Hi, 

I tried, but could not reproduce the problem you described here. Can you post a small test case?

Cheers,
Thomas

-----Original Message-----
From: Stephen Watson [mailto:community-noreply@qnx.com] 
Sent: Montag, 27. Februar 2012 12:58
To: photon-graphics
Subject: Timer widgets come back from the dead

I am updating a QNX 4.25 application to work on 6.5.  It has a Photon GUI controlled with a keypad with the number 
digits and a few function keys.  The GUI consists of a base window with a pane.  This pane gets realized from a picture 
module in response to events triggered by the function keys (done with PtTab and PtGroup, not PtPanelGroup).

What I find happens is if I show a pane that contains a PtTimer or sometimes PtClock, then replace that pane with 
another:
 PtClearWidget(ABW_Pane);
 ApCreateModule(ABM_NewPane_Module, ABW_Pane, NULL);
 PtReRealizeWidget(ABW_Pane):

then although the PtTimer widget is unrealized, after the call to PtReRealizeWidget it has been re-realized even though 
it is not part of AMB_NewPane_Module.  I can put debug statements into Realized and UnRealized callbacks and see this 
happen.  The widget flags go from 0x1 to 0x1000 (Pt_REALIZED to Pt_DESTROYED), then 0x1000 to 0x1001 (destroyed and 
realized!).

When the PtTimer activate event happens, the event loop gets horribly confused looking up the callback function.  I 
either get a SIGSEGV in in the Photon library or it spins madly in the event handling code.

What is going wrong?




_______________________________________________

Photon microGUI
http://community.qnx.com/sf/go/post91801
Re: RE: Timer widgets come back from the dead  
> Hi, 
> 
> I tried, but could not reproduce the problem you described here. Can you post 
> a small test case?

Not yet.  A new program and widget set, entirely from scratch, does not show the problem.  Cutting my code down to the 
bare minimum does, as does wiping out the code, reinstating the minimum and re-using the widget files.

I am currently suspecting the widget files.  As I said, this was a QNX 4 project and I converted the widget files by 
passing them through PhAB.  Maybe there is a subtle problem in there?

Attached is the reimplemented source file.  Setup() is called on program start and loads the first pane (contains a 
PtTimer) then selects the tab.  Selecting the tab calls XXXSummary() (not the original name).  Then I trigger 
SelectDiagnostics() via key event callback, that selects another tab. Info() is called by the tab callback, this clears 
the pane (which should unrealize the PtTimer) and loads the replacement.  I then check the status of the timer and if it
 is still realized I abort.

All other callbacks (and there are many) do nothing except return Pt_CONTINUE.
Attachment: Text Actions.cc 2.64 KB
Re: RE: Timer widgets come back from the dead  
Latest discovery: the picture module that gets replaced contained a number of PtPane widgets with Pt_GETS_FOCUS set.  If
 I unset Pt_GETS_FOCUS, the expected crash doesn't happen.  
Re: RE: Timer widgets come back from the dead  
I'm having some success with a workaround suggested by Thomas Haupt.  I replaced the calls to PtClearWidget (or at least
 the ones that clear panes containing timers) with calls to my own ClearWidget function.  This function calls 
PtClearWidget, then PtReRealizeWidget.  I think this gives the Photon library the chance to clear up the widgets so they
 don't get ressurected later.
RE: RE: Timer widgets come back from the dead  
Hi Stephen,

great you got a workaround working.

As I pointed out to you offline, the root cause of the problem is that the timer widgets already marked as "destroyed" 
get "realized" (and hence, activated) again when you call PtReRealize() on their ancestor. If you don't want to take any
 chances, add some code to your "ClearWidget()" function to iterate all children of the container first and for all 
PtTimer widgets found set the Pt_ARG_TIMER_INITIAL resource to 0, so the timers will be deactivated for sure.

Kind regards,
Thomas

-----Original Message-----
From: Stephen Watson [mailto:community-noreply@qnx.com] 
Sent: Mittwoch, 4. April 2012 10:40
To: photon-graphics
Subject: Re: RE: Timer widgets come back from the dead

I'm having some success with a workaround suggested by Thomas Haupt.  I replaced the calls to PtClearWidget (or at least
 the ones that clear panes containing timers) with calls to my own ClearWidget function.  This function calls 
PtClearWidget, then PtReRealizeWidget.  I think this gives the Photon library the chance to clear up the widgets so they
 don't get ressurected later.



_______________________________________________

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