Bug 328967

Summary: An exception in a slot called by a signal emitted in MyMoneyFile::commitTransaction() causes a crash with useless error message
Product: [Applications] kmymoney Reporter: Christian David <christian-david>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: REPORTED ---    
Severity: wishlist    
Priority: NOR    
Version: git (master)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: All   
Latest Commit: Version Fixed In:

Description Christian David 2013-12-18 15:33:10 UTC
An exception in a slot called by a signal emitted in MyMoneyFile::commitTransaction() causes a crash in a way that it is really hard for a developer to find the root of all evil.

The reason is that the MyMoneyFileTransaction can have m_needRollback == true even if the commit was finished and MyMoneyFile::d->m_inTransaction was set false already.

An uncaught exception causes the MyMoneyFileTransaction to be destructed which starts a rollback then. MyMoneyFile::rollbackTransaction() detects that no transaction was started (because it is finished already). This leads to another exception which makes it really hard to find the bug.

During normal usage this should not happen anyway and the data is as save as in any other uncaught exception. It is unlikly that this leads to other bugs. Just reported it here because a bug based on this is really hard to find and share my experience. A fix is not urgent nor necessary.

Reproducible: Always

Steps to Reproduce:
1. connect a slot to any signal of MyMoneyFile (which is emitted during commitTransaction())
2. throw an exception in this slot
3. change data & commit a transaction in a way that your slot called
Actual Results:  
KMyMoney crashes with unusable error message.

Expected Results:  
Crash with usable error message.