Auto save doesn't rescue subsheets

Bug #1426748 reported by michalstec
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
High
Blair Bonnett

Bug Description

Only changes in top level can be rescued after crash.

Steps to reproduce 1:
1. Create root sheet and add subsheets
2. Set auto save to 1 min
3. Draw something in the sheets and close KiCad
4. Remove auto save ($...) files
5. Run KiCad in terminal, open root and go to some subsheet immediately
6. Make changes in subsheet and wait 1 min - auto save file of subsheet is created
7. Kill KiCad (ctrl+c)
8. Run eeschema - there is no proposition to get changes from auto save file

Steps to reproduce 2:
1. Make steps 1, 2, 3, 4 as above
2. Run KiCad in terminal and make changes in root and in some subsheet
3. After 1 min auto save files of root and subsheet are created
4. Kill and open KiCad - you can rescue root but changes from subsheets are lost.

Application: kicad
Version: (2015-02-26 BZR 5453)-product Release build
wxWidgets: Version 3.0.1 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.8.2,wx containers,compatible with 2.8)
Platform: Linux 3.13.0-37-generic x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON
         KICAD_USE_WEBKIT=ON

Revision history for this message
Blair Bonnett (bcb) wrote :

I can't reproduce this in either case. When just editing the sub-sheet, I get a dialog

> Well this is potentially embarrassing! It appears that the
> last time you were editing the file 'subsheet.sch' it was not
> saved properly. Do you wish to restore the last edits you made?

when I reopen. If I edit both the main sheet and sub-sheet then I get two dialogs in a row, one for each file.

This is using the latest version (BZR 5464) on Arch Linux. Can you please try with the latest version and see if this still occurs for you?

-----------------------------------------------------------------

Application: kicad
Version: (2015-02-28 BZR 5464)-product Debug build
wxWidgets: Version 3.0.2 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.9.2,wx containers,compatible with 2.8)
Platform: Linux 3.18.6-1-ARCH x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.57.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON
         KICAD_USE_WEBKIT=ON

Changed in kicad:
status: New → Incomplete
Revision history for this message
michalstec (nnn4000) wrote :

I get the dialog if I make changes in created but not saved sheet. To improve my "steps to reproduce": save subsheet before making modifications.

Revision history for this message
Blair Bonnett (bcb) wrote :

Thats how I was testing it anyway. To make sure we're both doing the same procedure, here are the steps I have been testing it with:

1. File -> New -> Blank project (/tmp/foo/foo.pro)
2. Open Eeschema, agree to create /tmp/foo/foo.sch
3. Set auto-save time to one minute.
4. Add a couple of resistors.
5. Add a hierarchical sheet, /tmp/foo/subsheet.sch
6. Save the top-level sheet.
7. Open the sub-sheet, add a couple of capacitors, and save it.
8. Close KiCad.
9. Check there are no auto-save files.
10. Run KiCad from the terminal.
11. Open the sub-sheet and add a resistor.
12. Wait for a minute (until an auto-save file $subsheet.sch is created).
13. Kill KiCad with Ctrl-C from the terminal.
14. Open KiCad and then Eeschema.
15. Get dialog box:

> Well this is potentially embarrassing! It appears that the last time you were
> editing the file 'subsheet.sch' it was not saved properly. Do you wish to
> restore the last edits you made?

16. Click yes, then open sub-sheet. Resistor added in step 11 has been recovered.

If I make changes to both the main and sub-sheet in step 11, I get two dialog boxes in step 15 and both files are successfully recovered.

If I click No to restoring the edits, the old unmodified sheets are opened i.e., there is no other mechanism doing the recovery.

Are these the steps that you are following to trigger the bug? If so, can you please try with the latest revision to see if it still occurs. If not, please point out where my steps differ.

Revision history for this message
michalstec (nnn4000) wrote :

I've build the latest verision and followed the steps you wrote but I didn't get the dialog.
Auto-save file is created and it contains proper content but eeschema doesn't open it. The file is removed when I close eeschema.
I've no idea where is the difference.

Revision history for this message
Blair Bonnett (bcb) wrote :

What distribution are you using? Also, can you copy-paste the version information from your latest build?

If I get time, I may try building with the same versions of the dependencies (e.g., your wxWidgets is a different version to mine) to see if I can reproduce it.

Revision history for this message
michalstec (nnn4000) wrote :

I use linux mint mate 17.1.

Application: kicad
Version: (2015-03-03 BZR 5469)-product Release build
wxWidgets: Version 3.0.1 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.8.2,wx containers,compatible with 2.8)
Platform: Linux 3.13.0-37-generic x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON
         KICAD_USE_WEBKIT=ON

I tested also ubuntu daily builds on linux mint cinnamon on virtualbox and ubuntu daily builds on ubuntu on virtualbox.

Revision history for this message
Blair Bonnett (bcb) wrote :

So I installed VirtualBox, created a VM running Linux Mint Mate 17.1, and built KiCad with the same settings (only difference is wxWidgets 3.0.2 vs 3.0.1; I installed it from Adam Wolf's backports PPA to get wxPython), and the bug occurs for me too.

Next step is to do a debug build, confirm the bug also occurs in a debug build, and then I'll have a go at tracking through the code with gdb to see whats going on here.

Changed in kicad:
assignee: nobody → Blair Bonnett (bcb)
importance: Undecided → High
status: Incomplete → Confirmed
Revision history for this message
Blair Bonnett (bcb) wrote :

This happens on any build; the way I was testing it earlier didn't expose it. This is an issue with the way that eeschema searches for autosave files. The easiest way to see it is to run KiCad using strace to print the stat() calls that are made. When running from inside the project directory:

$ cd ~/scratch/kicad-autosave-bug
$ cp bugtest.sch \$bugtest.sch
$ cp subsheet.sch \$subsheet.sch
$ strace -etrace=stat kicad

stat("/mnt/data/scratch/kicad-autosave-bug/$bugtest.sch", {st_mode=S_IFREG|0644, st_size=1140, ...}) = 0
stat("$subsheet.sch", {st_mode=S_IFREG|0644, st_size=1052, ...}) = 0

Both autosave files are found, and I get the recovery dialogue for both sheets. However, if I try again from outside the project directory:

$ cp bugtest.sch \$bugtest.sch
$ cp subsheet.sch \$subsheet.sch
$ cd ../
$ strace -etrace=stat kicad

stat("/mnt/data/scratch/kicad-autosave-bug/$bugtest.sch", {st_mode=S_IFREG|0644, st_size=1140, ...}) = 0
stat("$subsheet.sch", 0x7ffd16b3ba60) = -1 ENOENT (No such file or directory)

The subsheet file is not found because a relative path is expanded from the working directory of the process. Hence the recovery dialogue only comes up for the main sheet.

To fix this, we need to either expand the filename ourselves (is it relative to its parent sheet, or relative to the top-level sheet?), or set the working directory.

Revision history for this message
Blair Bonnett (bcb) wrote :

The attached patch fixes this for me.

The SCH_EDIT_FRAME::LoadOneEEFile() method already expands the filename relative to the project directory. However, this was done after the autosave check which therefore only used the relative path leading to this bug. The patch just moves the expansion to earlier in the method and uses it when checking for autosave files.

Changed in kicad:
status: Confirmed → Fix Committed
Jon Neal (reportingsjr)
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.