Possible fix for #13821: wxRichTextCtrl using 100% CPU
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70264 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -125,6 +125,9 @@ public:
|
|||||||
|
|
||||||
void Notify();
|
void Notify();
|
||||||
|
|
||||||
|
bool GetRefreshEnabled() const { return m_refreshEnabled; }
|
||||||
|
void EnableRefresh(bool b) { m_refreshEnabled = b; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoShow();
|
virtual void DoShow();
|
||||||
virtual void DoHide();
|
virtual void DoHide();
|
||||||
@@ -144,6 +147,7 @@ private:
|
|||||||
bool m_flashOn;
|
bool m_flashOn;
|
||||||
wxRichTextCaretTimer m_timer;
|
wxRichTextCaretTimer m_timer;
|
||||||
wxRichTextCtrl* m_richTextCtrl;
|
wxRichTextCtrl* m_richTextCtrl;
|
||||||
|
bool m_refreshEnabled;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -406,6 +410,11 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
#if !wxRICHTEXT_USE_OWN_CARET
|
#if !wxRICHTEXT_USE_OWN_CARET
|
||||||
if (GetCaret() && !IsFrozen())
|
if (GetCaret() && !IsFrozen())
|
||||||
GetCaret()->Hide();
|
GetCaret()->Hide();
|
||||||
|
#else
|
||||||
|
// Stop the caret refreshing the control from within the
|
||||||
|
// paint handler
|
||||||
|
if (GetCaret())
|
||||||
|
((wxRichTextCaret*) GetCaret())->EnableRefresh(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -460,6 +469,7 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
#if wxRICHTEXT_USE_OWN_CARET
|
#if wxRICHTEXT_USE_OWN_CARET
|
||||||
if (GetCaret()->IsVisible())
|
if (GetCaret()->IsVisible())
|
||||||
{
|
{
|
||||||
|
PositionCaret();
|
||||||
((wxRichTextCaret*) GetCaret())->DoDraw(& dc);
|
((wxRichTextCaret*) GetCaret())->DoDraw(& dc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -470,10 +480,8 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
GetCaret()->Show();
|
GetCaret()->Show();
|
||||||
PositionCaret();
|
PositionCaret();
|
||||||
#else
|
#else
|
||||||
#if !defined(__WXMAC__)
|
if (GetCaret())
|
||||||
// Causes caret dropouts on Mac
|
((wxRichTextCaret*) GetCaret())->EnableRefresh(true);
|
||||||
PositionCaret();
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4413,6 +4421,7 @@ bool wxRichTextDropSource::GiveFeedback(wxDragResult WXUNUSED(effect))
|
|||||||
void wxRichTextCaret::Init()
|
void wxRichTextCaret::Init()
|
||||||
{
|
{
|
||||||
m_hasFocus = true;
|
m_hasFocus = true;
|
||||||
|
m_refreshEnabled = true;
|
||||||
|
|
||||||
m_xOld =
|
m_xOld =
|
||||||
m_yOld = -1;
|
m_yOld = -1;
|
||||||
@@ -4457,7 +4466,7 @@ void wxRichTextCaret::DoMove()
|
|||||||
|
|
||||||
if (m_xOld != -1 && m_yOld != -1)
|
if (m_xOld != -1 && m_yOld != -1)
|
||||||
{
|
{
|
||||||
if (m_richTextCtrl)
|
if (m_richTextCtrl && m_refreshEnabled)
|
||||||
{
|
{
|
||||||
wxRect rect(GetPosition(), GetSize());
|
wxRect rect(GetPosition(), GetSize());
|
||||||
m_richTextCtrl->RefreshRect(rect, false);
|
m_richTextCtrl->RefreshRect(rect, false);
|
||||||
@@ -4508,7 +4517,7 @@ void wxRichTextCaret::OnKillFocus()
|
|||||||
|
|
||||||
void wxRichTextCaret::Refresh()
|
void wxRichTextCaret::Refresh()
|
||||||
{
|
{
|
||||||
if (m_richTextCtrl)
|
if (m_richTextCtrl && m_refreshEnabled)
|
||||||
{
|
{
|
||||||
wxRect rect(GetPosition(), GetSize());
|
wxRect rect(GetPosition(), GetSize());
|
||||||
m_richTextCtrl->RefreshRect(rect, false);
|
m_richTextCtrl->RefreshRect(rect, false);
|
||||||
|
Reference in New Issue
Block a user