From 08c1613f889a3239c6392b4828c07dd4a00bac22 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sat, 29 Aug 2009 08:09:45 +0000 Subject: [PATCH] Disabled top-level parent tracking by default (crashes with AUI), must now use wxPG_EX_ENABLE_TLP_TRACKING style to enable old behavior. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61779 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/doxygen/overviews/propgrid.h | 4 ++++ include/wx/propgrid/propgrid.h | 19 ++++++++++++++++++- interface/wx/propgrid/propgrid.h | 19 ++++++++++++++++--- samples/propgrid/propgrid.cpp | 7 ++++--- samples/propgrid/tests.cpp | 2 +- src/propgrid/propgrid.cpp | 30 +++++++++++++++++++++--------- 6 files changed, 64 insertions(+), 17 deletions(-) diff --git a/docs/doxygen/overviews/propgrid.h b/docs/doxygen/overviews/propgrid.h index 4029cc907a..c3798068a7 100644 --- a/docs/doxygen/overviews/propgrid.h +++ b/docs/doxygen/overviews/propgrid.h @@ -923,6 +923,10 @@ without warnings or errors. - wxPropertyGridInterface::GetExpandedProperties() is removed. You should now use wxPropertyGridInterface::GetEditableState() instead. + - wxPG_EX_DISABLE_TLP_TRACKING is now enabled by default. To get the old + behavior (recommended if you don't use a system that reparents the grid + on its own), use the wxPG_EX_ENABLE_TLP_TRACKING extra style. + - Extended window style wxPG_EX_LEGACY_VALIDATORS was removed. - wxPropertyGridManager now has same Get/SetSelection() semantics as diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index aa6c9cea1b..a46583491e 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -260,10 +260,27 @@ wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000, selected). Other useful member functions are ClearSelection(), AddToSelection() and RemoveFromSelection(). */ -wxPG_EX_MULTIPLE_SELECTION = 0x02000000 +wxPG_EX_MULTIPLE_SELECTION = 0x02000000, + +/** + This enables top-level window tracking which allows wxPropertyGrid to + notify the application of last-minute property value changes by user. + + This style is not enabled by default because it may cause crashes when + wxPropertyGrid is used in with wxAUI or similar system. + + @remarks If you are not in fact using any system that may change + wxPropertyGrid's top-level parent window on its own, then you + are recommended to enable this style. +*/ +wxPG_EX_ENABLE_TLP_TRACKING = 0x04000000 }; +#if wxPG_COMPATIBILITY_1_4 + #define wxPG_EX_DISABLE_TLP_TRACKING 0x00000000 +#endif + /** Combines various styles. */ #define wxPG_DEFAULT_STYLE (0) diff --git a/interface/wx/propgrid/propgrid.h b/interface/wx/propgrid/propgrid.h index bfe94e4bc5..622be65cf4 100644 --- a/interface/wx/propgrid/propgrid.h +++ b/interface/wx/propgrid/propgrid.h @@ -165,17 +165,30 @@ wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000, selected). Other useful member functions are ClearSelection(), AddToSelection() and RemoveFromSelection(). */ -wxPG_EX_MULTIPLE_SELECTION = 0x02000000 +wxPG_EX_MULTIPLE_SELECTION = 0x02000000, + +/** + This enables top-level window tracking which allows wxPropertyGrid to + notify the application of last-minute property value changes by user. + + This style is not enabled by default because it may cause crashes when + wxPropertyGrid is used in with wxAUI or similar system. + + @remarks If you are not in fact using any system that may change + wxPropertyGrid's top-level parent window on its own, then you + are recommended to enable this style. +*/ +wxPG_EX_ENABLE_TLP_TRACKING = 0x04000000 }; /** Combines various styles. */ -#define wxPG_DEFAULT_STYLE (0) +#define wxPG_DEFAULT_STYLE (0) /** Combines various styles. */ -#define wxPGMAN_DEFAULT_STYLE (0) +#define wxPGMAN_DEFAULT_STYLE (0) /** @} */ diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index c148abf8a1..d31328837a 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -2965,6 +2965,7 @@ void FormMain::OnSelectStyle( wxCommandEvent& WXUNUSED(event) ) ADD_FLAG(wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES) ADD_FLAG(wxPG_EX_HIDE_PAGE_BUTTONS) ADD_FLAG(wxPG_EX_MULTIPLE_SELECTION) + ADD_FLAG(wxPG_EX_ENABLE_TLP_TRACKING) wxMultiChoiceDialog dlg( this, wxT("Select extra window styles to use"), wxT("wxPropertyGrid Extra Style"), chs ); dlg.SetSelections(sel); @@ -3175,8 +3176,8 @@ bool cxApplication::OnInit() //wxLocale Locale; //Locale.Init(wxLANGUAGE_FINNISH); - FormMain* frame = Form1 = new FormMain( wxT("wxPropertyGrid Sample"), wxPoint(0,0), wxSize(300,500) ); - frame->Show(true); + FormMain* frame = Form1 = new FormMain( wxT("wxPropertyGrid Sample"), wxPoint(0,0), wxSize(300,500) ); + frame->Show(true); // // Parse command-line @@ -3195,7 +3196,7 @@ bool cxApplication::OnInit() } } - return true; + return true; } // ----------------------------------------------------------------------- diff --git a/samples/propgrid/tests.cpp b/samples/propgrid/tests.cpp index c2b5e5b953..28d553b068 100644 --- a/samples/propgrid/tests.cpp +++ b/samples/propgrid/tests.cpp @@ -1237,7 +1237,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive ) wxASSERT(wxPG_EX_INIT_NOCAT == 0x00001000); - for ( i=12; i<26; i++ ) + for ( i=12; i<27; i++ ) { int flag = 1<ReleaseMouse(); // Call with NULL to disconnect event handling - OnTLPChanging(NULL); + if ( GetExtraStyle() & wxPG_EX_ENABLE_TLP_TRACKING ) + { + OnTLPChanging(NULL); - wxASSERT_MSG( !IsEditorsValueModified(), - wxS("Most recent change in property editor was lost!!! ") - wxS("(if you don't want this to happen, close your frames ") - wxS("and dialogs using Close(false).)") ); + wxASSERT_MSG( !IsEditorsValueModified(), + wxS("Most recent change in property editor was ") + wxS("lost!!! (if you don't want this to happen, ") + wxS("close your frames and dialogs using ") + wxS("Close(false).)") ); + } #if wxPG_DOUBLE_BUFFER if ( m_doubleBuffer ) @@ -1061,6 +1064,11 @@ void wxPropertyGrid::DoEndLabelEdit( bool commit, int selFlags ) void wxPropertyGrid::SetExtraStyle( long exStyle ) { + if ( exStyle & wxPG_EX_ENABLE_TLP_TRACKING ) + OnTLPChanging(::wxGetTopLevelParent(this)); + else + OnTLPChanging(NULL); + if ( exStyle & wxPG_EX_NATIVE_DOUBLE_BUFFERING ) { #if defined(__WXMSW__) @@ -1131,6 +1139,9 @@ wxSize wxPropertyGrid::DoGetBestSize() const void wxPropertyGrid::OnTLPChanging( wxWindow* newTLP ) { + if ( newTLP == m_tlp ) + return; + wxLongLong currentTime = ::wxGetLocalTimeMillis(); // @@ -5383,10 +5394,11 @@ void wxPropertyGrid::OnIdle( wxIdleEvent& WXUNUSED(event) ) // // Check if top-level parent has changed - wxWindow* tlp = ::wxGetTopLevelParent(this); - if ( tlp != m_tlp ) + if ( GetExtraStyle() & wxPG_EX_ENABLE_TLP_TRACKING ) { - OnTLPChanging(tlp); + wxWindow* tlp = ::wxGetTopLevelParent(this); + if ( tlp != m_tlp ) + OnTLPChanging(tlp); } } -- 2.45.2