diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index a4e0a55fd6..8fe7bd3492 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -174,6 +174,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) void EDA_DRAW_PANEL_GAL::DoRePaint() { + if( !m_refreshMutex.try_lock() ) + return; + + std::lock_guard lock( m_refreshMutex, std::adopt_lock ); + // Repaint the canvas, and fix scrollbar cursors // Usually called by a OnPaint event, but because it does not use a wxPaintDC, // it can be called outside a wxPaintEvent. diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index b0d30d9e6d..478e96969f 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -253,6 +254,8 @@ protected: bool m_pendingRefresh; ///< Is there a redraw event requested? wxTimer m_refreshTimer; ///< Timer to prevent too-frequent refreshing + std::mutex m_refreshMutex; ///< Blocks multiple calls to the draw + /// True if GAL is currently redrawing the view bool m_drawing;