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:
@@ -50,6 +50,11 @@ public:
|
|||||||
|
|
||||||
const wxAcceleratorEntry *GetEntry(const wxKeyEvent& event) const;
|
const wxAcceleratorEntry *GetEntry(const wxKeyEvent& event) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// ref counting code
|
||||||
|
virtual wxObjectRefData *CreateRefData() const;
|
||||||
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
|
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
|
||||||
};
|
};
|
||||||
|
@@ -53,7 +53,16 @@ WX_DEFINE_LIST(wxAccelList);
|
|||||||
class wxAccelRefData : public wxObjectRefData
|
class wxAccelRefData : public wxObjectRefData
|
||||||
{
|
{
|
||||||
public:
|
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;
|
wxAccelList m_accels;
|
||||||
};
|
};
|
||||||
@@ -61,6 +70,7 @@ public:
|
|||||||
// macro which can be used to access wxAccelRefData from wxAcceleratorTable
|
// macro which can be used to access wxAccelRefData from wxAcceleratorTable
|
||||||
#define M_ACCELDATA ((wxAccelRefData *)m_refData)
|
#define M_ACCELDATA ((wxAccelRefData *)m_refData)
|
||||||
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -108,6 +118,8 @@ bool wxAcceleratorTable::Ok() const
|
|||||||
|
|
||||||
void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry)
|
void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry)
|
||||||
{
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
if ( !m_refData )
|
if ( !m_refData )
|
||||||
{
|
{
|
||||||
m_refData = new wxAccelRefData;
|
m_refData = new wxAccelRefData;
|
||||||
@@ -118,6 +130,8 @@ void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry)
|
|||||||
|
|
||||||
void wxAcceleratorTable::Remove(const wxAcceleratorEntry& entry)
|
void wxAcceleratorTable::Remove(const wxAcceleratorEntry& entry)
|
||||||
{
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst();
|
wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst();
|
||||||
while ( node )
|
while ( node )
|
||||||
{
|
{
|
||||||
@@ -189,5 +203,15 @@ int wxAcceleratorTable::GetCommand(const wxKeyEvent& event) const
|
|||||||
return entry ? entry->GetCommand() : -1;
|
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
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user