use YieldFor() in wxTopLevelWindowGTK::RequestUserAttention; comment on the use of YieldFor() in wxProgressDialog; add some TODOs near wxYieldIfNeeded()/wxSafeYield() calls in wxListCtrl, wxDataViewCtrl, wxTreeCtrl (closes #10320)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-02-15 15:42:15 +00:00
parent 31cb01131e
commit 977a41ec3e
5 changed files with 254 additions and 234 deletions

View File

@@ -1903,7 +1903,11 @@ void wxDataViewMainWindow::OnRenameTimer()
// We have to call this here because changes may just have // We have to call this here because changes may just have
// been made and no screen update taken place. // been made and no screen update taken place.
if ( m_dirty ) if ( m_dirty )
{
// TODO: use wxTheApp->SafeYieldFor(NULL, wxEVT_CATEGORY_UI) instead
// (needs to be tested!)
wxSafeYield(); wxSafeYield();
}
int xpos = 0; int xpos = 0;
unsigned int cols = GetOwner()->GetColumnCount(); unsigned int cols = GetOwner()->GetColumnCount();

View File

@@ -2243,6 +2243,9 @@ wxTextCtrl *wxListMainWindow::EditLabel(long item, wxClassInfo* textControlClass
// been added and no screen update taken place. // been added and no screen update taken place.
if ( m_dirty ) if ( m_dirty )
{ {
// TODO: use wxTheApp->SafeYieldFor(NULL, wxEVT_CATEGORY_UI) instead
// so that no pending events may change the item count (see below)
// IMPORTANT: needs to be tested!
wxSafeYield(); wxSafeYield();
// Pending events dispatched by wxSafeYield might have changed the item // Pending events dispatched by wxSafeYield might have changed the item

View File

@@ -403,6 +403,9 @@ wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
m_msg->SetLabel(_("Done.")); m_msg->SetLabel(_("Done."));
} }
// allow the window to repaint:
// NOTE: since we yield only for UI events with this call, there
// should be no side-effects
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
(void)ShowModal(); (void)ShowModal();
@@ -453,6 +456,8 @@ bool wxProgressDialog::DoAfterUpdate(bool *skip)
{ {
// we have to yield because not only we want to update the display but // we have to yield because not only we want to update the display but
// also to process the clicks on the cancel and skip buttons // also to process the clicks on the cancel and skip buttons
// NOTE: using YieldFor() this call shouldn't give re-entrancy problems
// for event handlers not interested to UI/user-input events.
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT);
Update(); Update();
@@ -672,6 +677,9 @@ void wxProgressDialog::UpdateMessage(const wxString &newmsg)
Fit(); // adapt to the new label size Fit(); // adapt to the new label size
// allow the window to repaint:
// NOTE: since we yield only for UI events with this call, there
// should be no side-effects
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
} }
} }

View File

@@ -3576,6 +3576,8 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK20__) #if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXGTK20__)
Update(); Update();
#else #else
// TODO: remove this call or use wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI)
// instead (needs to be tested!)
wxYieldIfNeeded(); wxYieldIfNeeded();
#endif #endif
} }
@@ -3606,9 +3608,11 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
SetCursor(m_oldCursor); SetCursor(m_oldCursor);
#if defined( __WXMSW__ ) || defined(__WXMAC__) #if defined( __WXMSW__ ) || defined(__WXMAC__) || defined(__WXGTK20__)
Update(); Update();
#else #else
// TODO: remove this call or use wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI)
// instead (needs to be tested!)
wxYieldIfNeeded(); wxYieldIfNeeded();
#endif #endif
} }

View File

@@ -1247,10 +1247,11 @@ void wxTopLevelWindowGTK::RequestUserAttention(int flags)
bool new_hint_value = false; bool new_hint_value = false;
// FIXME: This is a workaround to focus handling problem // FIXME: This is a workaround to focus handling problem
// If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle hasn't // If RequestUserAttention is called for example right after a wxSleep, OnInternalIdle
// yet been processed, and the internal focus system is not up to date yet. // hasn't yet been processed, and the internal focus system is not up to date yet.
// wxYieldIfNeeded ensures the processing of it, but can have unwanted side effects - MR // YieldFor(wxEVT_CATEGORY_UI) ensures the processing of it (hopefully it
::wxYieldIfNeeded(); // won't have side effects) - MR
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
if(m_urgency_hint >= 0) if(m_urgency_hint >= 0)
g_source_remove(m_urgency_hint); g_source_remove(m_urgency_hint);