I bumped into a crash with wxPropertyGrid & wxAUI when having a property grid on a floating wxAUI pane. I noticed that wxPropertyGrid caches the top level parent (m_tlp member variable) upon construction, and if it's constructed on a floating pane and the pane is closed after, then the m_tlp is invalidated. Closing an wxAUI pane is supposed to only hide the pane, but apparently the enclosing window is destroyed instead when the window is floating. Shouldn't m_tlp be initialized with the parent you pass to the wxPropertyGrid constructor instead?
When I replaced m_tlp=::wxGetTopLevelParent(this); with m_tlp=GetParent(); it seems to fix it and property grid seems to also function properly otherwise as well after a quick test. What's the purpose of m_tlp exactly?
Top-level parent (m_tlp) is hooked with event handler to prevent it from being closed if property has invalid value. I'm pretty sure close events are only sent to top-level windows, so just using the parent will not work properly.
I will try to come up with a solution that will not break any old behavior. Reimplementing Reparent(), assuming it is virtual, might work for some cases (maybe even yours, if you did not have intermediate window/panel).
I changed the offending wxAUI panes in my app to wxMiniFrame for other reasons, so it'n not a blocking issue for me anymore (for now).
Log in to post a comment.