Bug 356399 - crash while saving file after report change with data loss
Summary: crash while saving file after report change with data loss
Status: RESOLVED WORKSFORME
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR critical
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
: 361271 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-12-08 19:38 UTC by Michał Walenciak
Modified: 2017-11-11 23:38 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Walenciak 2015-12-08 19:38:15 UTC
I've edited one of existing report templates (Income and Expenses By Year). After that I pressed Ctrl+S and it caused application to crash. What is worse my .kmy file become 0 bytes in size (luckly I had fresh backup).

It happens every time I try to reproduce it.

Reproducible: Always

Steps to Reproduce:
1. edit Income and Expenses By Year report template
2. save kmy file
3. crash
Comment 1 Christian David 2016-03-24 21:00:09 UTC
Git commit 8319120b9c810574beb0de97fc44e49315de058d by Christian Dávid.
Committed on 24/03/2016 at 20:30.
Pushed by christiand into branch 'frameworks'.

Changed way of saving files which should fix some bugs

The save operation seems to fail every time - it never changed the
orginal file and never reported any issues. I did not find the exact
reason for this bug but I am quite sure it was caused by an incorret
usage of QSaveFile (under some circumstances close() instead of commit()
was called).

Now KMyMoney creates its own temporary file to write to (if needed).
This also works using KGpgFile, which should fix Bug 356399.

The remove() and rename() operations are not atomic which is not so
good as this could result in dataloss if the first operation fails.
However, this is the best OS independet process I could find.

Errors during writing of compressed files may not be detected. I think
this issue should be fixed upstream.
FIXED-IN: 5.0
REVIEW: 127108

M  +2    -2    CMakeLists.txt
M  +81   -82   kmymoney/views/kmymoneyview.cpp
M  +1    -5    kmymoney/views/kmymoneyview.h

http://commits.kde.org/kmymoney/8319120b9c810574beb0de97fc44e49315de058d
Comment 2 Christian David 2016-03-24 21:04:01 UTC
Sorry, the patch does not fix the crash. Only the file should not be lost anymore (hopefully).
Comment 3 Michał Walenciak 2016-03-26 12:11:56 UTC
I'll try it as soon as KMyMoney is updated in arch repos.
Comment 4 Christian David 2016-04-01 19:05:05 UTC
*** Bug 361271 has been marked as a duplicate of this bug. ***
Comment 5 NSLW 2017-07-30 06:53:18 UTC
No crash on master branch. Attach .kmy test case file and write steps to reproduce you issue.
Comment 6 Michał Walenciak 2017-08-05 08:24:34 UTC
I can confirm I have no crash any more. KMyMoney version 4.8.0