use (new) safer GetTraitsIfExists() in wxMutexGuiEnter/Leave() to avoid crashing on exit of wxGTK1 applications putting anything on clipboard (and maybe other cases)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54735 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4010aae119
commit
96b2cbe8b3
@ -198,6 +198,13 @@ public:
|
||||
// allows us to abstract the differences behind the common facade
|
||||
wxAppTraits *GetTraits();
|
||||
|
||||
// this function provides safer access to traits object than
|
||||
// wxTheApp->GetTraits() during startup or termination when the global
|
||||
// application object itself may be unavailable
|
||||
//
|
||||
// of course, it still returns NULL in this case and the caller must check
|
||||
// for it
|
||||
static wxAppTraits *GetTraitsIfExists();
|
||||
|
||||
// event processing functions
|
||||
// --------------------------
|
||||
|
@ -290,6 +290,13 @@ wxAppTraits *wxAppConsoleBase::GetTraits()
|
||||
return m_traits;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxAppTraits *wxAppConsoleBase::GetTraitsIfExists()
|
||||
{
|
||||
wxAppConsole * const app = GetInstance();
|
||||
return app ? app->GetTraits() : NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event processing
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -673,12 +680,16 @@ void wxAppTraitsBase::MutexGuiLeave()
|
||||
|
||||
void WXDLLIMPEXP_BASE wxMutexGuiEnter()
|
||||
{
|
||||
wxAppConsoleBase::GetInstance()->GetTraits()->MutexGuiEnter();
|
||||
wxAppTraits * const traits = wxAppConsoleBase::GetTraitsIfExists();
|
||||
if ( traits )
|
||||
traits->MutexGuiEnter();
|
||||
}
|
||||
|
||||
void WXDLLIMPEXP_BASE wxMutexGuiLeave()
|
||||
{
|
||||
wxAppConsoleBase::GetInstance()->GetTraits()->MutexGuiLeave();
|
||||
wxAppTraits * const traits = wxAppConsoleBase::GetTraitsIfExists();
|
||||
if ( traits )
|
||||
traits->MutexGuiLeave();
|
||||
}
|
||||
#endif // wxUSE_THREADS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user