wx.lib.agw.aui

Hi Andrea,

I wonder if this could be improved.

- Created an AUI layout
- mgr.Update()
- add a panel to a panel in the above layout
- forgot to call mgr.Update()
- Python crash without any exception hint

When I run it through the debugger the crash happens in DoFrameLayout line 6756:

part.rect = part.sizer_item.GetRect()

part.sizer_item returns a wx._core.SizerItem but If I do GetRect() on that it crashes.

Is there some way of checking if a SizerItem is valid/correct or in other words what might be the reason that GetRect is causing the crash.

Tried to recreate it in the demo but no success, so I guess it is time for a small app, unless ...?

Werner

Hi Werner,

Hi Andrea,

I wonder if this could be improved.

- Created an AUI layout
- mgr.Update()
- add a panel to a panel in the above layout
- forgot to call mgr.Update()
- Python crash without any exception hint

When I run it through the debugger the crash happens in DoFrameLayout line
6756:

part.rect = part.sizer_item.GetRect()

part.sizer_item returns a wx._core.SizerItem but If I do GetRect() on that
it crashes.

Is there some way of checking if a SizerItem is valid/correct or in other
words what might be the reason that GetRect is causing the crash.

Tried to recreate it in the demo but no success, so I guess it is time for a
small app, unless ...?

Uhm, I am not sure, I wasn't expecting a Python hard crash... anyway,
can you try and see if the following commands:

print part.sizer_item.GetPosition(), part.sizer_item.GetSize()

do anything? Do they crash Python as well? If they do, can you see
what this command:

print part.sizer_item.GetFlag()

returns?

If it is zero, then we have a way to check for this issue. Otherwise,
I will have to think about it a bit more...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 10 April 2012 17:06, Werner wrote:

I hate it when this happens:-( , sorry can't recreate it any more.

Will give an update as soon as I can recreate it again.

Werner

···

On 10/04/2012 17:41, Andrea Gavana wrote:

Hi Werner,

On 10 April 2012 17:06, Werner wrote:

Hi Andrea,

I wonder if this could be improved.

- Created an AUI layout
- mgr.Update()
- add a panel to a panel in the above layout
- forgot to call mgr.Update()
- Python crash without any exception hint

When I run it through the debugger the crash happens in DoFrameLayout line
6756:

part.rect = part.sizer_item.GetRect()

part.sizer_item returns a wx._core.SizerItem but If I do GetRect() on that
it crashes.

Is there some way of checking if a SizerItem is valid/correct or in other
words what might be the reason that GetRect is causing the crash.

Tried to recreate it in the demo but no success, so I guess it is time for a
small app, unless ...?

Uhm, I am not sure, I wasn't expecting a Python hard crash... anyway,
can you try and see if the following commands:

print part.sizer_item.GetPosition(), part.sizer_item.GetSize()

do anything? Do they crash Python as well? If they do, can you see
what this command:

print part.sizer_item.GetFlag()

returns?

If it is zero, then we have a way to check for this issue. Otherwise,
I will have to think about it a bit more...

Hi Werner,

Hi Andrea,

I wonder if this could be improved.

- Created an AUI layout
- mgr.Update()
- add a panel to a panel in the above layout
- forgot to call mgr.Update()
- Python crash without any exception hint

When I run it through the debugger the crash happens in DoFrameLayout line
6756:

part.rect = part.sizer_item.GetRect()

part.sizer_item returns a wx._core.SizerItem but If I do GetRect() on that
it crashes.

Is there some way of checking if a SizerItem is valid/correct or in other
words what might be the reason that GetRect is causing the crash.

Tried to recreate it in the demo but no success, so I guess it is time for a
small app, unless ...?

Uhm, I am not sure, I wasn't expecting a Python hard crash... anyway,
can you try and see if the following commands:

print part.sizer_item.GetPosition(), part.sizer_item.GetSize()

do anything? Do they crash Python as well? If they do, can you see
what this command:

print part.sizer_item.GetFlag()

returns?

If it is zero, then we have a way to check for this issue. Otherwise,
I will have to think about it a bit more...

O.K., got it again.

There was more then just one pane added, some buttons and a lib.agw.InfoBar.

GetFlag, GetPosition and GetSize also cause it to crash.

Is this of any use?

Werner

Following some info I see in the Wing debugger, but not sure that gets us anywhere.

__module__ = "wx._core"
Ratio = <property object at 0x02D12C90>
Sizer = <property object at 0x02D12D20>
thisown = <property object at 0x02D12B10>
Proportion = <property object at 0x02D12C60>
MinSize = <property object at 0x02D12BD0>
Window = <property object at 0x02D12DB0>
Position = <property object at 0x02D12C30>
UserData = <property object at 0x02D12D80>
this = _f0c8a403_p_wxSizerItem
Spacer = <property object at 0x02D12D50>
Id = <property object at 0x02D12DE0>
MinSizeWithBorder = <property object at 0x02D12C00>
Flag = <property object at 0x02D12BA0>
Border = <property object at 0x02D12B70>
__doc__ = "\n The wx.SizerItem class is used to track the position, size a...
Rect = <property object at 0x02D12CC0>
Size = <property object at 0x02D12CF0>

If I look at self._uiparts[0] I see this:
__module__ = "wx.lib.agw.aui.framemanager"
typeDock = 2
typePaneBorder = 7
dock = <wx.lib.agw.aui.framemanager.AuiDockInfo 0x676e710; len=1>
pane = <wx.lib.agw.aui.framemanager.AuiPaneInfo 0x676e590; len=1>
__dict__ = <attribute '__dict__' of 'AuiDockUIPart' objects>
__weakref__ = <attribute '__weakref__' of 'AuiDockUIPart' objects>
rect = <wx._core.Rect 0x676e770; len=5>
orientation = 8
typeDockSizer = 3
typePaneButton = 8
typeCaption = 0
sizer_item = <wx._core.SizerItem 0x676e870; len=1>
button = None
cont_sizer = <wx._core._wxPyDeadObject 0x676e850; len=1>
typePane = 4
__doc__ = " A class which holds attributes for a UI part in the interface. "
typePaneSizer = 5
typeGripper = 1
type = 4
typeBackground = 6

···

On 10/04/2012 17:41, Andrea Gavana wrote:

On 10 April 2012 17:06, Werner wrote:

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

Hi Werner,

Hi Werner,

Hi Andrea,

I wonder if this could be improved.

- Created an AUI layout
- mgr.Update()
- add a panel to a panel in the above layout
- forgot to call mgr.Update()
- Python crash without any exception hint

When I run it through the debugger the crash happens in DoFrameLayout
line
6756:

part.rect = part.sizer_item.GetRect()

part.sizer_item returns a wx._core.SizerItem but If I do GetRect() on
that
it crashes.

Is there some way of checking if a SizerItem is valid/correct or in other
words what might be the reason that GetRect is causing the crash.

Tried to recreate it in the demo but no success, so I guess it is time
for a
small app, unless ...?

Uhm, I am not sure, I wasn't expecting a Python hard crash... anyway,
can you try and see if the following commands:

print part.sizer_item.GetPosition(), part.sizer_item.GetSize()

do anything? Do they crash Python as well? If they do, can you see
what this command:

print part.sizer_item.GetFlag()

returns?

If it is zero, then we have a way to check for this issue. Otherwise,
I will have to think about it a bit more...

O.K., got it again.

There was more then just one pane added, some buttons and a lib.agw.InfoBar.

GetFlag, GetPosition and GetSize also cause it to crash.

This is very curious, as even if I do this on an empty Python prompt:

import wx
dummy = wx.SizerItem() # This is an "invalid" SizerItem
dummy.GetFlag()

0

<snip>

If I look at self._uiparts[0] I see this:
__module__ = "wx.lib.agw.aui.framemanager"
typeDock = 2
typePaneBorder = 7
dock = <wx.lib.agw.aui.framemanager.AuiDockInfo 0x676e710; len=1>
pane = <wx.lib.agw.aui.framemanager.AuiPaneInfo 0x676e590; len=1>
__dict__ = <attribute '__dict__' of 'AuiDockUIPart' objects>
__weakref__ = <attribute '__weakref__' of 'AuiDockUIPart' objects>
rect = <wx._core.Rect 0x676e770; len=5>
orientation = 8
typeDockSizer = 3
typePaneButton = 8
typeCaption = 0
sizer_item = <wx._core.SizerItem 0x676e870; len=1>
button = None
cont_sizer = <wx._core._wxPyDeadObject 0x676e850; len=1>

^^^^^^^^^^^^^^^^

This is *very* bad. How did you manage to get a wx.PyDeadObject sizer
object?!?! Anyway, as far as I can see the method DoFrameLayout is
only called when you call Update() and OnSize(), nowhere else... So I
am a bit puzzled, but there might still be some hope: are you doing
anything fancy with wx.EVT_SIZE handlers somewhere? Do you get
anything out if you use:

print part.pane.window?

I.e., what window is involved? (I have a feeling it might be InfoBar...)

Other than that, I could put a guard checking against wx.PyDeadObject
errors, but I am not sure it's going to make much of a difference
(other than raising an Exception instead of a crash, maybe).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 10 April 2012 20:14, Werner wrote:

On 10/04/2012 17:41, Andrea Gavana wrote:

On 10 April 2012 17:06, Werner wrote:

Hi Andrea,

...

cont_sizer =<wx._core._wxPyDeadObject 0x676e850; len=1>
^^^^^^^^^^^^^^^^

This is *very* bad. How did you manage to get a wx.PyDeadObject sizer
object?!?!

No idea, the crash is showing on my side when I call ShowModal and I also see a call to Layout.

  Anyway, as far as I can see the method DoFrameLayout is
only called when you call Update() and OnSize(), nowhere else... So I
am a bit puzzled, but there might still be some hope: are you doing
anything fancy with wx.EVT_SIZE handlers somewhere?

No.

  Do you get
anything out if you use:

print part.pane.window?

I.e., what window is involved? (I have a feeling it might be InfoBar...)

Other than that, I could put a guard checking against wx.PyDeadObject
errors, but I am not sure it's going to make much of a difference
(other than raising an Exception instead of a crash, maybe).

That would already be better as it took me some time to find the reason.

You mean an try/except PyDeadObject within DoFrameLayout, yes?

I'll try that later this evening or tomorrow.

Werner

···

On 10/04/2012 20:31, Andrea Gavana wrote:

Hi Werner,

Hi Andrea,

...

cont_sizer =<wx._core._wxPyDeadObject 0x676e850; len=1>
^^^^^^^^^^^^^^^^

This is *very* bad. How did you manage to get a wx.PyDeadObject sizer
object?!?!

No idea, the crash is showing on my side when I call ShowModal and I also
see a call to Layout.

Anyway, as far as I can see the method DoFrameLayout is
only called when you call Update() and OnSize(), nowhere else... So I
am a bit puzzled, but there might still be some hope: are you doing
anything fancy with wx.EVT_SIZE handlers somewhere?

No.

Do you get
anything out if you use:

print part.pane.window?

I.e., what window is involved? (I have a feeling it might be InfoBar...)

Other than that, I could put a guard checking against wx.PyDeadObject
errors, but I am not sure it's going to make much of a difference
(other than raising an Exception instead of a crash, maybe).

That would already be better as it took me some time to find the reason.

You mean an try/except PyDeadObject within DoFrameLayout, yes?

That's a possibility, yes. The other possibility is to set some kind
of flag (like self._needsLayout) to ``True`` every time a pane is
added, and then re-setting it to ``False`` when Update() is called.
So, if DoFrameLayout finds that flag to be ``True``, it simply calls
Update() and returns without doing anything.

All of this is of course speculation, as I don't have a sample app to
play with so I can only apply blind patches.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 10 April 2012 20:52, Werner wrote:

On 10/04/2012 20:31, Andrea Gavana wrote:

Hi Andrea,

..

That would already be better as it took me some time to find the reason.

You mean an try/except PyDeadObject within DoFrameLayout, yes?
That's a possibility, yes. The other possibility is to set some kind
of flag (like self._needsLayout) to ``True`` every time a pane is
added, and then re-setting it to ``False`` when Update() is called.
So, if DoFrameLayout finds that flag to be ``True``, it simply calls
Update() and returns without doing anything.

All of this is of course speculation, as I don't have a sample app to
play with so I can only apply blind patches.

Will try and get a sample app together when I figure out what the real cause is. I think it would take me to long to create a smallish sample at the point as I/we are still hitting blindly at things.
Just to try and narrow it down I did this in DoFrameLayout:

if part.cont_sizer:
....
else:
      print part.cont_sizer

I get quit a few:
wxPython wrapper for DELETED BoxSizer object! (The C++ object no longer exists.)

But no more hard crash.

If I add back my mgr.Update() then I am fine.

It might have to do with the sized_controls as with them one can do:

panel.SetSizerType(..... and in which case the old sizer gets destroyed and new one created and childrens are added to the new one.

Just a suspicion at this point, will try and narrow this further down tomorrow.

Werner

···

On 10/04/2012 21:02, Andrea Gavana wrote:

Hi Werner,

Hi Andrea,

I wonder if this could be improved.

- Created an AUI layout
- mgr.Update()
- add a panel to a panel in the above layout
- forgot to call mgr.Update()
- Python crash without any exception hint

When I run it through the debugger the crash happens in DoFrameLayout line
6756:

part.rect = part.sizer_item.GetRect()

part.sizer_item returns a wx._core.SizerItem but If I do GetRect() on that
it crashes.

Is it possible that the item represented by part.sizer_item has been removed from the sizer? If so then the C++ object pointed to by part.sizer_item will have been deleted and so that pointer is no longer valid.

Ah, I see from later messages that apparently the sizer is gone. If so then the SizerItems it held are definitely gone too, and so that pointer in the Python proxy object will be bad.

Is there some way of checking if a SizerItem is valid/correct or in other
words what might be the reason that GetRect is causing the crash.

Probably the only way to check validity is to see if there is still an item in the sizer with the same .this value. (NOTE: the .this values will not exist in Phoenix)

···

On 4/10/12 8:41 AM, Andrea Gavana wrote:

On 10 April 2012 17:06, Werner wrote:

--
Robin Dunn
Software Craftsman

Hi,

I tried to come up with a small sample on this one too, but no luck till now.

I can force it to happen in the application, so I still must do something which invalidates the sizers, the ones shown:

wxPython wrapper for DELETED BoxSizer object! (The C++ object no longer exists.)

Look like they are AUI sizers as a lot of mine are FlexGrid and there is no error for them.

Andrea, any idea/tip/hint on what I might do which invalidates the AUI sizers?

In the mean time I put a this into framemanager.DoFrameLayout so to at least not to get a hard crash:

             if part.cont_sizer:
                 part.rect = part.sizer_item.GetRect()
                 flag = part.sizer_item.GetFlag()
                 border = part.sizer_item.GetBorder()
                 ... etc etc

             else:
                 print 'this should never happen: %s' % part.cont_sizer

I'll keep trying to work out what the real reason is.

Werner

Hi Werner,

Hi,

I tried to come up with a small sample on this one too, but no luck till
now.

I can force it to happen in the application, so I still must do something
which invalidates the sizers, the ones shown:

wxPython wrapper for DELETED BoxSizer object! (The C++ object no longer
exists.)

Look like they are AUI sizers as a lot of mine are FlexGrid and there is no
error for them.

Andrea, any idea/tip/hint on what I might do which invalidates the AUI
sizers?

I am not sure, but one thing you can do to help here is to try and
modify your if condition below to make it become like this:

           if part.cont_sizer:
               part.rect = part.sizer_item.GetRect()
               flag = part.sizer_item.GetFlag()
               border = part.sizer_item.GetBorder()
               ... etc etc

           else:
               print 'this should never happen: ', part.pane.window,
part.pane.name

So that at least we have an indication of what window(s) are involved
and (maybe) what could cause this issue.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 11 April 2012 12:11, Werner wrote:

Getting closer with this, there are SizedScrolledPanel's and only two out of the many I use in this dialog.

Will try and see what I do different on those two.

Werner

···

On 11/04/2012 13:55, Andrea Gavana wrote:

I am not sure, but one thing you can do to help here is to try and
modify your if condition below to make it become like this:

            if part.cont_sizer:
                part.rect = part.sizer_item.GetRect()
                flag = part.sizer_item.GetFlag()
                border = part.sizer_item.GetBorder()
                ... etc etc

            else:
                print 'this should never happen: ', part.pane.window,
part.pane.name

So that at least we have an indication of what window(s) are involved
and (maybe) what could cause this issue.