Fixed, patch attached.

On Wed, Aug 05, 2015 at 06:46:43PM +0200, jp charras wrote:
> Le 05/08/2015 16:29, Wayne Stambaugh a écrit :
> > Patch committed in product branch r6053.  Thanks.
> > 
> > On 8/4/2015 5:32 PM, Chris Pavlina wrote:
> >> In any case, here's the patch to make undo configurable. I can edit it 
> >> to change the default if you like.
> 
> Thanks, Chris.
> 
> I just tested this feature.
> It looks good but I noticed a minor and strange issue (only tested on
> Windows currently):
> 
> the undo level value seems not (or incorrectly) read from config for the
> schematic editor only.
> After closing the schematic editor and re-run it, the undo level
> selection is always 0 (regardless the previous setting) if it is run
> from kicad manager
> However, if Eeschema is run in stand alone mode, after closing Eeschema
> and re-run it, the undo level selection is good (is is the last saved value)
> I am thinking this is a read config issue when eeschema is run from
> kicad manager.
> (Because if I run eeschema from kicad manager and set the undo stack to
> 3 and close kicad, if I run eeschema in stand alone, the undo stack is 3
> (as expected), but if I run eeschema from kicad manager, the undo stack
> is 0)
> 
> No problem for other editors.
> 
> 
> 
> -- 
> Jean-Pierre CHARRAS
> 
> _______________________________________________
> 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
commit d66ccb3a3e6846368696460e38991d716c70ce30
Author: Chris Pavlina <cpavl...@binghamton.edu>
Date:   Wed Aug 5 16:07:23 2015 -0400

    Fix loading of undo settings

diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp
index fcffdc9..1b5d3ad 100644
--- a/common/draw_frame.cpp
+++ b/common/draw_frame.cpp
@@ -676,8 +676,8 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
     if( m_LastGridSizeId < 0 )
         m_LastGridSizeId = 0;
 
-    GetScreen()->SetMaxUndoItems( aCfg->Read( baseCfgName + MaxUndoItemsEntry,
-                long( DEFAULT_MAX_UNDO_ITEMS ) ) );
+    m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
+            long( DEFAULT_MAX_UNDO_ITEMS ) );
 }
 
 
diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp
index b4135fd..c898c38 100644
--- a/eeschema/files-io.cpp
+++ b/eeschema/files-io.cpp
@@ -430,7 +430,9 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
                     sheet->SetName( tmp );
 
                 sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ), (long) newtimestamp ) );
-                sheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
+                SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
+                screen->SetMaxUndoItems( m_UndoRedoCountMax );
+                sheet->SetScreen( screen );
                 sheet->GetScreen()->SetFileName( sheet->GetFileName() );
             }
             // clear annotation and init new time stamp for the new components
diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp
index b428b30..0eb1d36 100644
--- a/eeschema/libeditframe.cpp
+++ b/eeschema/libeditframe.cpp
@@ -206,13 +206,14 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
     icon.CopyFromBitmap( KiBitmap( libedit_icon_xpm ) );
     SetIcon( icon );
 
+    LoadSettings( config() );
+
     SetScreen( new SCH_SCREEN( aKiway ) );
     GetScreen()->m_Center = true;
+    GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
 
     SetCrossHairPosition( wxPoint( 0, 0 ) );
 
-    LoadSettings( config() );
-
     // Ensure m_LastGridSizeId is an offset inside the allowed schematic range
     if( m_LastGridSizeId < ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000 )
         m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp
index 4afc8fd..5d4e345 100644
--- a/eeschema/load_one_schematic_file.cpp
+++ b/eeschema/load_one_schematic_file.cpp
@@ -66,6 +66,9 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
     if( aFullFileName.IsEmpty() )
         return false;
 
+    // Place the undo limit into the screen
+    aScreen->SetMaxUndoItems( m_UndoRedoCountMax );
+
     // If path is relative, this expands it from the project directory.
     wxString fname = Prj().AbsolutePath( aFullFileName );
 
diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp
index c9afde7..ddce303 100644
--- a/eeschema/sch_sheet.cpp
+++ b/eeschema/sch_sheet.cpp
@@ -755,9 +755,9 @@ bool SCH_SHEET::Load( SCH_EDIT_FRAME* aFrame )
 {
     bool success = true;
 
+    SCH_SCREEN* screen = NULL;
     if( !m_screen )
     {
-        SCH_SCREEN* screen = NULL;
         g_RootSheet->SearchHierarchy( m_fileName, &screen );
 
         if( screen )
diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp
index 15ee725..d0aa2f4 100644
--- a/eeschema/schframe.cpp
+++ b/eeschema/schframe.cpp
@@ -348,8 +348,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
     SetSpiceAddReferencePrefix( false );
     SetSpiceUseNetcodeAsNetname( false );
 
-    CreateScreens();
-
     // Give an icon
     wxIcon icon;
     icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
@@ -361,6 +359,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
 
     LoadSettings( config() );
 
+    CreateScreens();
+
     // Ensure m_LastGridSizeId is an offset inside the allowed schematic grid range
     if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
         m_LastGridSizeId = default_grid;
@@ -523,7 +523,9 @@ void SCH_EDIT_FRAME::CreateScreens()
 
     if( g_RootSheet->GetScreen() == NULL )
     {
-        g_RootSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
+        SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
+        screen->SetMaxUndoItems( m_UndoRedoCountMax );
+        g_RootSheet->SetScreen( screen );
         SetScreen( g_RootSheet->GetScreen() );
     }
 
@@ -533,7 +535,11 @@ void SCH_EDIT_FRAME::CreateScreens()
     m_CurrentSheet->Push( g_RootSheet );
 
     if( GetScreen() == NULL )
-        SetScreen( new SCH_SCREEN( &Kiway() ) );
+    {
+        SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
+        screen->SetMaxUndoItems( m_UndoRedoCountMax );
+        SetScreen( screen );
+    }
 
     GetScreen()->SetZoom( 32.0 );
 }
diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp
index e532ec4..d4fb0f2 100644
--- a/eeschema/sheet.cpp
+++ b/eeschema/sheet.cpp
@@ -141,6 +141,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy )
         else                                                   // New file.
         {
             aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
+            aSheet->GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
             aSheet->GetScreen()->SetFileName( newFilename );
         }
     }
diff --git a/include/class_base_screen.h b/include/class_base_screen.h
index 82da9ff..fe77668 100644
--- a/include/class_base_screen.h
+++ b/include/class_base_screen.h
@@ -31,15 +31,12 @@
 #ifndef  CLASS_BASE_SCREEN_H_
 #define  CLASS_BASE_SCREEN_H_
 
+#include <draw_frame.h>
 #include <base_struct.h>
 #include <class_undoredo_container.h>
 #include <block_commande.h>
 #include <common.h>
 #include <id.h>
-#include <climits>
-
-#define DEFAULT_MAX_UNDO_ITEMS 0
-#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
 
 /**
  * Class GRID_TYPE
diff --git a/include/draw_frame.h b/include/draw_frame.h
index d787a4f..d88ca5c 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -27,10 +27,14 @@
 
 #include <wxstruct.h>
 #include <kiway_player.h>
+#include <climits>
 
 class wxSingleInstanceChecker;
 class EDA_HOTKEY;
 
+#define DEFAULT_MAX_UNDO_ITEMS 0
+#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
+
 /**
  * Class EDA_DRAW_FRAME
  * is the base class for create windows for drawing purpose.  The Eeschema, Pcbnew and
@@ -68,6 +72,8 @@ protected:
     double      m_zoomLevelCoeff;           ///< a suitable value to convert the internal zoom scaling factor
                                             // to a zoom level value which rougly gives 1.0 when the board/schematic
                                             // is at scale = 1
+    int         m_UndoRedoCountMax;         ///< default Undo/Redo command Max depth, to be handed
+                                            // to screens
 
     /// The area to draw on.
     EDA_DRAW_PANEL* m_canvas;
diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp
index 4337a8d..79d68f9 100644
--- a/pcbnew/moduleframe.cpp
+++ b/pcbnew/moduleframe.cpp
@@ -246,10 +246,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
     wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
     m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas(), font.GetPointSize(), true );
 
+    LoadSettings( config() );
     SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
-
+    GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
     GetScreen()->SetCurItem( NULL );
-    LoadSettings( config() );
 
     GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
     GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp
index 33faef8..9f84003 100644
--- a/pcbnew/pcbframe.cpp
+++ b/pcbnew/pcbframe.cpp
@@ -352,15 +352,16 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
     icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
     SetIcon( icon );
 
+    // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
+    // initialize parameters in m_LayersManager
+    LoadSettings( config() );
+
     SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
+    GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
 
     // PCB drawings start in the upper left corner.
     GetScreen()->m_Center = false;
 
-    // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
-    // initialize parameters in m_LayersManager
-    LoadSettings( config() );
-
     SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
 
     GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
_______________________________________________
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