Updated patch attached (missed initializers in the original)

On Wed, Jan 10, 2018 at 11:40 PM, Jon Evans <j...@craftyjon.com> wrote:

> Hopefully this fixes:
> https://bugs.launchpad.net/kicad/+bug/1741787
> although I don't currently have a good way of reproducing the crash.
>
> Chris, if you can give it a try on your crashing machine that would be
> greatly appreciated.
>
> Thanks
> -Jon
>
From 1eb7a5ca257a9e8d0a5dfad08ed74f3a238df2b0 Mon Sep 17 00:00:00 2001
From: Jon Evans <j...@craftyjon.com>
Date: Thu, 11 Jan 2018 23:02:18 -0500
Subject: [PATCH] Defer canvas type setting save until destruction of 
 EDA_DRAW_FRAME

Fixes: lp:1741787
* https://bugs.launchpad.net/kicad/+bug/1741787
---
 common/draw_frame.cpp                | 5 +++++
 gerbview/events_called_functions.cpp | 4 +++-
 include/draw_frame.h                 | 6 ++++++
 pcbnew/basepcbframe.cpp              | 4 +++-
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp
index bd9342155..49b2df5c6 100644
--- a/common/draw_frame.cpp
+++ b/common/draw_frame.cpp
@@ -142,6 +142,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
     m_hotkeysDescrList    = NULL;
 
     m_canvas              = NULL;
+    m_canvasType          = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
+    m_canvasTypeDirty     = false;
     m_galCanvas           = NULL;
     m_galCanvasActive     = false;
     m_actions             = NULL;
@@ -216,6 +218,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
 
 EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
 {
+    if( m_canvasTypeDirty )
+        saveCanvasTypeSetting( m_canvasType );
+
     delete m_actions;
     delete m_toolManager;
     delete m_toolDispatcher;
diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp
index 05d611aac..222ff9953 100644
--- a/gerbview/events_called_functions.cpp
+++ b/gerbview/events_called_functions.cpp
@@ -563,10 +563,12 @@ void GERBVIEW_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
         break;
     }
 
-    saveCanvasTypeSetting( canvasType );
     UseGalCanvas( use_gal );
     wxUpdateUIEvent e;
     OnUpdateSwitchCanvas( e );
+
+    m_canvasType = canvasType;
+    m_canvasTypeDirty = true;
 }
 
 
diff --git a/include/draw_frame.h b/include/draw_frame.h
index 899c9784b..6d925eb52 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -141,6 +141,12 @@ protected:
     /// One-shot to avoid a recursive mouse event during hotkey movement
     bool            m_movingCursorWithKeyboard;
 
+    /// Flag indicating that drawing canvas type needs to be saved to config
+    bool            m_canvasTypeDirty;
+
+    /// The current canvas type
+    EDA_DRAW_PANEL_GAL::GAL_TYPE    m_canvasType;
+
     void SetScreen( BASE_SCREEN* aScreen )  { m_currentScreen = aScreen; }
 
     /**
diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp
index 54ba21cb7..62245fc45 100644
--- a/pcbnew/basepcbframe.cpp
+++ b/pcbnew/basepcbframe.cpp
@@ -958,7 +958,9 @@ void PCB_BASE_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
     }
 
     UseGalCanvas( use_gal );
-    saveCanvasTypeSetting( canvasType );
+
+    m_canvasType = canvasType;
+    m_canvasTypeDirty = true;
 }
 
 
-- 
2.14.1

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to