use AllocExclusive in wxAcceleratorTable

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14548 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2002-03-10 23:11:46 +00:00
parent b82d2a004d
commit fa03793d3b
2 changed files with 30 additions and 1 deletions

View File

@ -50,6 +50,11 @@ public:
const wxAcceleratorEntry *GetEntry(const wxKeyEvent& event) const;
protected:
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
private:
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
};

View File

@ -53,7 +53,16 @@ WX_DEFINE_LIST(wxAccelList);
class wxAccelRefData : public wxObjectRefData
{
public:
wxAccelRefData() { m_accels.DeleteContents(TRUE); }
wxAccelRefData()
{
m_accels.DeleteContents(TRUE);
}
wxAccelRefData(const wxAccelRefData& data)
{
m_accels.DeleteContents(TRUE);
m_accels = data.m_accels;
}
wxAccelList m_accels;
};
@ -61,6 +70,7 @@ public:
// macro which can be used to access wxAccelRefData from wxAcceleratorTable
#define M_ACCELDATA ((wxAccelRefData *)m_refData)
// ============================================================================
// implementation
// ============================================================================
@ -108,6 +118,8 @@ bool wxAcceleratorTable::Ok() const
void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry)
{
AllocExclusive();
if ( !m_refData )
{
m_refData = new wxAccelRefData;
@ -118,6 +130,8 @@ void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry)
void wxAcceleratorTable::Remove(const wxAcceleratorEntry& entry)
{
AllocExclusive();
wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst();
while ( node )
{
@ -189,5 +203,15 @@ int wxAcceleratorTable::GetCommand(const wxKeyEvent& event) const
return entry ? entry->GetCommand() : -1;
}
wxObjectRefData *wxAcceleratorTable::CreateRefData() const
{
return new wxAccelRefData;
}
wxObjectRefData *wxAcceleratorTable::CloneRefData(const wxObjectRefData *data) const
{
return new wxAccelRefData(*(wxAccelRefData *)data);
}
#endif // wxUSE_ACCEL