X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ee1377e1fa364f364b9a896c786c95ef177164cf..88ff049184c77fd73b60c01f4f831860d2ec5cef:/src/osx/dataview_osx.cpp diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index ecbf403f6b..799e752e15 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -2,7 +2,6 @@ // Name: src/osx/dataview_osx.cpp // Purpose: wxDataViewCtrl native mac implementation // Author: -// Id: $Id$ // Copyright: (c) 2009 // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -127,7 +126,7 @@ bool wxOSXDataViewModelNotifier::ItemChanged(wxDataViewItem const& item) if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) { // sent the equivalent wxWidget event: - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(m_DataViewCtrlPtr); dataViewEvent.SetItem(item); @@ -147,7 +146,7 @@ bool wxOSXDataViewModelNotifier::ItemsChanged(wxDataViewItemArray const& items) { size_t const noOfItems = items.GetCount(); - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(m_DataViewCtrlPtr); @@ -213,7 +212,7 @@ bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsign wxCHECK_MSG(GetOwner() != NULL,false,"Owner not initialized."); if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) { - wxDataViewEvent dataViewEvent(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); + wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); dataViewEvent.SetEventObject(m_DataViewCtrlPtr); dataViewEvent.SetColumn(col); @@ -348,6 +347,11 @@ void wxDataViewCustomRenderer::SetDC(wxDC* newDCPtr) wxDataViewCtrl::~wxDataViewCtrl() { ClearColumns(); + + // Ensure that the already destructed controls is not notified about changes + // in the model any more. + if (m_ModelNotifier != NULL) + m_ModelNotifier->GetOwner()->RemoveNotifier(m_ModelNotifier); } void wxDataViewCtrl::Init() @@ -355,6 +359,7 @@ void wxDataViewCtrl::Init() m_CustomRendererPtr = NULL; m_Deleting = false; m_cgContext = NULL; + m_ModelNotifier = NULL; } bool wxDataViewCtrl::Create(wxWindow *parent, @@ -381,10 +386,19 @@ bool wxDataViewCtrl::AssociateModel(wxDataViewModel* model) wxCHECK_MSG(dataViewWidgetPtr != NULL,false,"Pointer to native control must not be NULL."); + + // We could have been associated with another model previously, break the + // association in this case. + if ( m_ModelNotifier ) + m_ModelNotifier->GetOwner()->RemoveNotifier(m_ModelNotifier); + if (wxDataViewCtrlBase::AssociateModel(model) && dataViewWidgetPtr->AssociateModel(model)) { if (model != NULL) - model->AddNotifier(new wxOSXDataViewModelNotifier(this)); + { + m_ModelNotifier = new wxOSXDataViewModelNotifier(this); + model->AddNotifier(m_ModelNotifier); + } return true; } else @@ -635,9 +649,9 @@ void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem) (void) GetModel()->ItemsAdded(parentItem,items); } -void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int column ) +void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) { - GetDataViewPeer()->StartEditor(item, column); + GetDataViewPeer()->StartEditor(item, GetColumnPosition(column)); } void wxDataViewCtrl::FinishCustomItemEditing()