Jacob <email@example.com> wrote:
I am using PhAB to create several PtWindows for displaying stored images. I
have a dialog box that has buttons with callback links to create these
windows. This box also has a button to refresh images in these windows.
The code snip from the refresh routine is:
if( PtWidgetIsRealized( ABW_dply_image1 ) != 0)
When I run the program and click on the refresh image button, the program
crashes with a Memory Fault(core dumped). If I run the program, open the
image window and click on the refresh image button, the program doesn’t
Why is this happening? Is there another way to detect if a window has been
realized/created? I tried using PtWidgetFlags, but it also causes the
program to crash.
There’s a big difference between “realized” and “created”. If the
window hasn’t been created, its ABW pointer is NULL. Many Photon
functions will crash if you pass NULL instead of a widget pointer, and
PtWidgetIsRealized() is one of them.
You could check ABW_dply_image1 for NULL to find out whether the window
has been created, but since the ABW pointers for a window module don’t
get reset back to NULL when the window is destroyed, you’d have to do it
yourself, perhaps in a destroyed callback.
Of course, things get more complicated if you can have multiple
instances of this module; you’ll have to keep track of them yourself.
If you never possibly create more than one instance of the window, it
might make sense for the window to be a dialog module in PhAB. When a
dialog window is destroyed, PhAB library does reset its ABW pointer to
Wojtek Lerch QNX Software Systems Ltd.