Do not statically construct wxTimer

If you construct wxTimer statically, it will be constructed
before WX init, which means you might get assertions about
missing m_impl's within the timer class.

The solution is to construct the wxTimer at run time. In this
case, static within the function will be constructed only after
the function is called (and actually the scope only needed to be
this function anyway).
This commit is contained in:
John Beard 2019-05-23 10:41:06 +01:00
parent 75cea18f07
commit e1f6230e8c
1 changed files with 6 additions and 6 deletions

View File

@ -118,9 +118,6 @@ TOOL_ACTION EE_ACTIONS::toggleForceHV( "eeschema.EditorControl.forceHVLines",
lines90_xpm );
// A timer during which a subsequent FindNext will result in a wrap-around
static wxTimer g_wrapAroundTimer;
// A dummy wxFindReplaceData signalling any marker should be found
static wxFindReplaceData g_markersOnly;
@ -212,6 +209,9 @@ EDA_ITEM* nextMatch( SCH_SCREEN* aScreen, EDA_ITEM* after, wxFindReplaceData* da
int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
{
// A timer during which a subsequent FindNext will result in a wrap-around
static wxTimer wrapAroundTimer;
wxFindReplaceData* data = m_frame->GetFindReplaceData();
if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
@ -232,11 +232,11 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
EDA_ITEM* afterItem = selection.Front();
EDA_ITEM* item = nullptr;
if( g_wrapAroundTimer.IsRunning() )
if( wrapAroundTimer.IsRunning() )
{
afterScreen = nullptr;
afterItem = nullptr;
g_wrapAroundTimer.Stop();
wrapAroundTimer.Stop();
m_frame->ClearFindReplaceStatus();
}
@ -297,7 +297,7 @@ int SCH_EDITOR_CONTROL::FindNext( const TOOL_EVENT& aEvent )
msg = _( "Reached end of sheet." );
m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
g_wrapAroundTimer.StartOnce( 4000 );
wrapAroundTimer.StartOnce( 4000 );
}
return 0;