X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b90c32b486407a69ed81e8991c2ec8a6e0602431..cea4cc794274ae3dcd20133f009d74eaaa7d1c1e:/src/generic/accel.cpp diff --git a/src/generic/accel.cpp b/src/generic/accel.cpp index d99b55cea6..edf52970cd 100644 --- a/src/generic/accel.cpp +++ b/src/generic/accel.cpp @@ -53,7 +53,20 @@ WX_DEFINE_LIST(wxAccelList); class wxAccelRefData : public wxObjectRefData { public: - wxAccelRefData() { m_accels.DeleteContents(TRUE); } + wxAccelRefData() + { + } + + wxAccelRefData(const wxAccelRefData& data) + : wxObjectRefData() + { + m_accels = data.m_accels; + } + + virtual ~wxAccelRefData() + { + WX_CLEAR_LIST(wxAccelList, m_accels); + } wxAccelList m_accels; }; @@ -61,6 +74,7 @@ public: // macro which can be used to access wxAccelRefData from wxAcceleratorTable #define M_ACCELDATA ((wxAccelRefData *)m_refData) + // ============================================================================ // implementation // ============================================================================ @@ -75,7 +89,7 @@ wxAcceleratorTable::wxAcceleratorTable() { } -wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[]) +wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]) { m_refData = new wxAccelRefData; @@ -108,6 +122,8 @@ bool wxAcceleratorTable::Ok() const void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry) { + AllocExclusive(); + if ( !m_refData ) { m_refData = new wxAccelRefData; @@ -118,14 +134,17 @@ void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry) void wxAcceleratorTable::Remove(const wxAcceleratorEntry& entry) { - wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst(); + AllocExclusive(); + + wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); while ( node ) { const wxAcceleratorEntry *entryCur = node->GetData(); if ( *entryCur == entry ) { - M_ACCELDATA->m_accels.DeleteNode(node); + delete node->GetData(); + M_ACCELDATA->m_accels.Erase(node); return; } @@ -149,7 +168,7 @@ wxAcceleratorTable::GetEntry(const wxKeyEvent& event) const return NULL; } - wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst(); + wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); while ( node ) { const wxAcceleratorEntry *entry = node->GetData(); @@ -189,5 +208,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