Fix locking scheme for double-clicks

In some cases, the events may be driven in the same thread, which can
lead to a deadlock.  Instead of waiting for the lock, simply refuse to
run if a loading system in in progress.

Fixes https://gitlab.com/kicad/code/kicad/issues/6606
This commit is contained in:
Seth Hillbrand 2020-12-03 14:29:24 -08:00
parent 7eea344f91
commit d7a6a2cc71
1 changed files with 16 additions and 4 deletions

View File

@ -317,7 +317,10 @@ void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName
KIWAY_PLAYER* frame;
// Prevent multiple KiFace loading at one time
const std::lock_guard<std::mutex> lock( m_loading );
if( !m_loading.try_lock() )
return;
const std::lock_guard<std::mutex> lock( m_loading, std::adopt_lock );
try
{
@ -365,7 +368,10 @@ void KICAD_MANAGER_FRAME::OnRunSchLibEditor( wxCommandEvent& event )
KIWAY_PLAYER* frame;
// Prevent multiple KiFace loading at one time
const std::lock_guard<std::mutex> lock( m_loading );
if( !m_loading.try_lock() )
return;
const std::lock_guard<std::mutex> lock( m_loading, std::adopt_lock );
try
{
@ -394,7 +400,10 @@ void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName )
KIWAY_PLAYER* frame;
// Prevent multiple KiFace loading at one time
const std::lock_guard<std::mutex> lock( m_loading );
if( !m_loading.try_lock() )
return;
const std::lock_guard<std::mutex> lock( m_loading, std::adopt_lock );
try
{
@ -440,7 +449,10 @@ void KICAD_MANAGER_FRAME::OnRunPcbFpEditor( wxCommandEvent& event )
KIWAY_PLAYER* frame;
// Prevent multiple KiFace loading at one time
const std::lock_guard<std::mutex> lock( m_loading );
if( !m_loading.try_lock() )
return;
const std::lock_guard<std::mutex> lock( m_loading, std::adopt_lock );
try
{