mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-03-23 10:18:40 +08:00
wxQt: Fix memory leak of wxTextAutoCompleteData
Delete wxTextEntry member pointer which was forgotten in 602f4f3
(2025-02-08, wxQt: Add auto-completion support to wxTextEntry).
Note that some code had to be moved to make full declaration of
wxTextAutoCompleteData available to wxTextEntry destructor, this commit
is best viewed using Git --color-moved option.
Closes #26283.
Closes #26310.
This commit is contained in:
committed by
Vadim Zeitlin
parent
8d483b5c75
commit
813a15c893
@@ -14,6 +14,7 @@ class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase
|
||||
{
|
||||
public:
|
||||
wxTextEntry();
|
||||
~wxTextEntry();
|
||||
|
||||
virtual void WriteText(const wxString& text) override;
|
||||
|
||||
|
||||
@@ -21,119 +21,6 @@
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
wxTextEntry::wxTextEntry()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::WriteText(const wxString& WXUNUSED(text))
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Remove(long from, long to)
|
||||
{
|
||||
const long insertionPoint = GetInsertionPoint();
|
||||
wxString string = GetValue();
|
||||
string.erase(from, to - from);
|
||||
SetValue(string);
|
||||
SetInsertionPoint( std::min(insertionPoint, static_cast<long>(string.length())) );
|
||||
}
|
||||
|
||||
void wxTextEntry::Copy()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Cut()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Paste()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Undo()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Redo()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTextEntry::CanUndo() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTextEntry::CanRedo() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTextEntry::SetInsertionPoint(long WXUNUSED(pos))
|
||||
{
|
||||
}
|
||||
|
||||
long wxTextEntry::GetInsertionPoint() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
long wxTextEntry::GetLastPosition() const
|
||||
{
|
||||
return GetValue().length();
|
||||
}
|
||||
|
||||
void wxTextEntry::SetSelection(long WXUNUSED(from), long WXUNUSED(to))
|
||||
{
|
||||
wxFAIL_MSG("wxTextEntry::SetSelection should be overridden");
|
||||
}
|
||||
|
||||
void wxTextEntry::GetSelection(long *from, long *to) const
|
||||
{
|
||||
// no unified get selection method in Qt (overridden in textctrl & combobox)
|
||||
// only called if no selection
|
||||
// If the return values from and to are the same, there is no
|
||||
// selection.
|
||||
{
|
||||
*from =
|
||||
*to = GetInsertionPoint();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTextEntry::IsEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTextEntry::SetEditable(bool WXUNUSED(editable))
|
||||
{
|
||||
}
|
||||
|
||||
wxString wxTextEntry::DoGetValue() const
|
||||
{
|
||||
return wxString();
|
||||
}
|
||||
|
||||
void wxTextEntry::DoSetValue(const wxString& value, int flags)
|
||||
{
|
||||
wxTextEntryBase::DoSetValue(value, flags);
|
||||
}
|
||||
|
||||
wxWindow *wxTextEntry::GetEditableWindow()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void wxTextEntry::EnableTextChangedEvents(bool enable)
|
||||
{
|
||||
wxWindow* const win = GetEditableWindow();
|
||||
|
||||
if ( win )
|
||||
win->GetHandle()->blockSignals(!enable);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// auto-completion
|
||||
// ----------------------------------------------------------------------------
|
||||
namespace
|
||||
{
|
||||
// This class is taken from Qt documentation "as is" to see "C:\Program Files"
|
||||
@@ -327,6 +214,129 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(wxTextAutoCompleteData);
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// wxTextEntry implementation
|
||||
// ============================================================================
|
||||
|
||||
wxTextEntry::wxTextEntry()
|
||||
{
|
||||
}
|
||||
|
||||
wxTextEntry::~wxTextEntry()
|
||||
{
|
||||
delete m_autoCompleteData;
|
||||
}
|
||||
|
||||
void wxTextEntry::WriteText(const wxString& WXUNUSED(text))
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Remove(long from, long to)
|
||||
{
|
||||
const long insertionPoint = GetInsertionPoint();
|
||||
wxString string = GetValue();
|
||||
string.erase(from, to - from);
|
||||
SetValue(string);
|
||||
SetInsertionPoint( std::min(insertionPoint, static_cast<long>(string.length())) );
|
||||
}
|
||||
|
||||
void wxTextEntry::Copy()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Cut()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Paste()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Undo()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextEntry::Redo()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTextEntry::CanUndo() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTextEntry::CanRedo() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTextEntry::SetInsertionPoint(long WXUNUSED(pos))
|
||||
{
|
||||
}
|
||||
|
||||
long wxTextEntry::GetInsertionPoint() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
long wxTextEntry::GetLastPosition() const
|
||||
{
|
||||
return GetValue().length();
|
||||
}
|
||||
|
||||
void wxTextEntry::SetSelection(long WXUNUSED(from), long WXUNUSED(to))
|
||||
{
|
||||
wxFAIL_MSG("wxTextEntry::SetSelection should be overridden");
|
||||
}
|
||||
|
||||
void wxTextEntry::GetSelection(long *from, long *to) const
|
||||
{
|
||||
// no unified get selection method in Qt (overridden in textctrl & combobox)
|
||||
// only called if no selection
|
||||
// If the return values from and to are the same, there is no
|
||||
// selection.
|
||||
{
|
||||
*from =
|
||||
*to = GetInsertionPoint();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTextEntry::IsEditable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTextEntry::SetEditable(bool WXUNUSED(editable))
|
||||
{
|
||||
}
|
||||
|
||||
wxString wxTextEntry::DoGetValue() const
|
||||
{
|
||||
return wxString();
|
||||
}
|
||||
|
||||
void wxTextEntry::DoSetValue(const wxString& value, int flags)
|
||||
{
|
||||
wxTextEntryBase::DoSetValue(value, flags);
|
||||
}
|
||||
|
||||
wxWindow *wxTextEntry::GetEditableWindow()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void wxTextEntry::EnableTextChangedEvents(bool enable)
|
||||
{
|
||||
wxWindow* const win = GetEditableWindow();
|
||||
|
||||
if ( win )
|
||||
win->GetHandle()->blockSignals(!enable);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// auto-completion
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTextEntry::DoAutoCompleteFileNames(int WXUNUSED(flags))
|
||||
{
|
||||
if ( m_autoCompleteData )
|
||||
|
||||
Reference in New Issue
Block a user