Don't provide wxSharedClientDataContainer::m_data accessors

This is not really necessary and breaks encapsulation of this private
method. It is enough to provide just a way to copy the data from another
object as this is all that the derived classes really need.
This commit is contained in:
Vadim Zeitlin
2022-04-28 00:36:40 +02:00
parent de8877d3ee
commit e2a5c1ffc8
3 changed files with 9 additions and 7 deletions

View File

@@ -181,8 +181,10 @@ public:
protected:
bool HasClientDataContainer() const { return m_data.get() != NULL; }
wxSharedPtr<wxClientDataContainer> GetClientDataContainer() const { return m_data; }
void SetClientDataContainer(wxSharedPtr<wxClientDataContainer> data) { m_data = data; }
void CopyClientDataContainer(const wxSharedClientDataContainer& other)
{
m_data = other.m_data;
}
private:
// Helper function that will create m_data if it is currently NULL

View File

@@ -79,7 +79,7 @@ void wxSharedClientDataContainer::SetClientObject(wxClientData *data)
wxClientData *wxSharedClientDataContainer::GetClientObject() const
{
return HasClientDataContainer() ? GetClientDataContainer()->GetClientObject() : NULL;
return HasClientDataContainer() ? m_data->GetClientObject() : NULL;
}
void wxSharedClientDataContainer::SetClientData(void *data)
@@ -89,7 +89,7 @@ void wxSharedClientDataContainer::SetClientData(void *data)
void *wxSharedClientDataContainer::GetClientData() const
{
return HasClientDataContainer() ? GetClientDataContainer()->GetClientData() : NULL;
return HasClientDataContainer() ? m_data->GetClientData() : NULL;
}
wxClientDataContainer *wxSharedClientDataContainer::GetValidClientData()

View File

@@ -255,7 +255,7 @@ int wxGridColumnOperations::GetFirstLine(const wxGrid *grid, wxGridWindow *gridW
wxGridCellWorker::wxGridCellWorker(const wxGridCellWorker& other)
{
SetClientDataContainer(other.GetClientDataContainer());
CopyClientDataContainer(other);
}
void wxGridCellWorker::SetParameters(const wxString& WXUNUSED(params))
@@ -450,7 +450,7 @@ wxGridCellAttr *wxGridCellAttr::Clone() const
m_editor->IncRef();
}
attr->SetClientDataContainer(GetClientDataContainer());
attr->CopyClientDataContainer(*this);
if ( IsReadOnly() )
attr->SetReadOnly();
@@ -494,7 +494,7 @@ void wxGridCellAttr::MergeWith(wxGridCellAttr *mergefrom)
}
if ( !HasClientDataContainer() && mergefrom->HasClientDataContainer() )
{
SetClientDataContainer(mergefrom->GetClientDataContainer());
CopyClientDataContainer(*mergefrom);
}
if ( !HasReadWriteMode() && mergefrom->HasReadWriteMode() )
SetReadOnly(mergefrom->IsReadOnly());