X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/338dd992160bf20205743c092b353d96ef7604fb..bb16e81453a02433f2a313037b1c9b62681b45b8:/src/motif/combobox.cpp diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index 098ed1b0cb..d1c470999e 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -29,9 +29,7 @@ void wxComboBoxCallback (Widget w, XtPointer clientData, XmComboBoxSelectionCallbackStruct * cbs); -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) -#endif bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, @@ -69,11 +67,6 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE), NULL); - XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, - (XtPointer) this); - XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, - (XtPointer) this); - int i; for (i = 0; i < n; i++) { @@ -93,6 +86,11 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, m_font = parent->GetFont(); ChangeFont(FALSE); + XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, + (XtPointer) this); + XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, + (XtPointer) this); + SetCanAddEventHandler(TRUE); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); @@ -153,6 +151,16 @@ void wxComboBox::Delete(int n) delete[] (char *)node->Data(); delete node; } + node = m_clientList.Nth( n ); + if (node) + { + if ( HasClientObjectData() ) + { + delete (wxClientData *)node->Data(); + } + delete node; + } + m_noStrings--; } @@ -160,6 +168,21 @@ void wxComboBox::Clear() { XmComboBoxDeleteAllItems((Widget) m_mainWidget); m_stringList.Clear(); + + if ( HasClientObjectData() ) + { + // destroy the data (due to Robert's idea of using wxList + // and not wxList we can't just say + // m_clientList.DeleteContents(TRUE) - this would crash! + wxNode *node = m_clientList.First(); + while ( node ) + { + delete (wxClientData *)node->Data(); + node = node->Next(); + } + } + m_clientList.Clear(); + m_noStrings = 0; } void wxComboBox::SetSelection (int n)