class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase
{
public:
- wxTextEntry() { }
+ wxTextEntry()
+ {
+#if wxUSE_OLE
+ m_enumStrings = NULL;
+#endif // wxUSE_OLE
+ }
// implement wxTextEntryBase pure virtual methods
virtual void WriteText(const wxString& text);
private:
// implement this to return the HWND of the EDIT control
virtual WXHWND GetEditHWND() const = 0;
+
+#if wxUSE_OLE
+ // enumerator for strings currently used for auto-completion or NULL
+ class wxIEnumString *m_enumStrings;
+#endif // wxUSE_OLE
};
#endif // _WX_MSW_TEXTENTRY_H_
m_index = 0;
}
+ void ChangeStrings(const wxArrayString& strings)
+ {
+ m_strings = strings;
+ Reset();
+ }
+
DECLARE_IUNKNOWN_METHODS;
virtual HRESULT STDMETHODCALLTYPE Next(ULONG celt,
virtual ~wxIEnumString() { }
- const wxArrayString m_strings;
+ wxArrayString m_strings;
unsigned m_index;
wxDECLARE_NO_COPY_CLASS(wxIEnumString);
bool wxTextEntry::AutoComplete(const wxArrayString& choices)
{
#ifdef HAS_AUTOCOMPLETE
+ // if we had an old enumerator we must reuse it as IAutoComplete doesn't
+ // free it if we call Init() again (see #10968) -- and it's also simpler
+ if ( m_enumStrings )
+ {
+ m_enumStrings->ChangeStrings(choices);
+ return true;
+ }
+
// create an object exposing IAutoComplete interface (don't go for
// IAutoComplete2 immediately as, presumably, it might be not available on
// older systems as otherwise why do we have both -- although in practice I
}
// associate it with our strings
- wxIEnumString *pEnumString = new wxIEnumString(choices);
- pEnumString->AddRef();
- hr = pAutoComplete->Init(GetEditHwnd(), pEnumString, NULL, NULL);
- pEnumString->Release();
+ m_enumStrings = new wxIEnumString(choices);
+ m_enumStrings->AddRef();
+ hr = pAutoComplete->Init(GetEditHwnd(), m_enumStrings, NULL, NULL);
+ m_enumStrings->Release();
if ( FAILED(hr) )
{
wxLogApiError(_T("IAutoComplete::Init"), hr);