Prevent multiple kiway from loading simultaneously
Each KIWAY_PLAYER has some initialization elements that may take time
before the frame is raised. If handling is returned to the UI during
that load, we can cause reentrant issues for players.
Fixes https://gitlab.com/kicad/code/kicad/issues/4284
Fixes https://gitlab.com/kicad/code/kicad/issues/3743
(cherry picked from commit 5b47d1a910
)
This commit is contained in:
parent
674226f99f
commit
916d06c1e6
|
@ -582,6 +582,9 @@ int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent )
|
|||
FRAME_T playerType = aEvent.Parameter<FRAME_T>();
|
||||
KIWAY_PLAYER* player;
|
||||
|
||||
// Prevent multiple KIWAY_PLAYER loading at one time
|
||||
const std::lock_guard<std::mutex> lock( m_loading );
|
||||
|
||||
try
|
||||
{
|
||||
player = m_frame->Kiway().Player( playerType, true );
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 CERN
|
||||
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -26,6 +26,7 @@
|
|||
#define KICAD_MANAGER_CONTROL_H
|
||||
|
||||
#include <tool/tool_interactive.h>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
class KICAD_MANAGER_FRAME;
|
||||
|
@ -63,6 +64,9 @@ public:
|
|||
private:
|
||||
///> Pointer to the currently used edit/draw frame.
|
||||
KICAD_MANAGER_FRAME* m_frame;
|
||||
|
||||
// Mutex to allow only a single KiFace to load at one time (released when loaded)
|
||||
std::mutex m_loading;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue