Bug 261886

Summary: Once KMM opened, by force of habit, I opened CSV import. When the plugin opened, I closed it immediately and KMM crashed.
Product: [Applications] kmymoney Reporter: allan <agander93>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version: SVN   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description allan 2011-01-02 18:43:44 UTC
Version:           SVN trunk (using KDE 4.5.85) 
OS:                Linux

Once KMM opened, by force of habit, I opened  CSV import.  Realising it wasn't needed for what I was intending to do, once the plugin opened, I closed it immediately, and KMM crashed.

The crash occurred here:-
RedefineDlg::~RedefineDlg()
{
  delete m_widget;
}.

My first thought was to test for m_widget being NULL before the delete.  On repeating the process, the identical crash occurred.

RedefineDlg() is called in the ctor of InvestmentDlg() - m_redefine = new RedefineDlg, and destroyed in its dtor.  So I repeated the NULL test here.  This time, there was no crash.

I then thought it could be a timing issue, as I had closed the plugin pretty quickly, so removed the NULL tests, and waited a few seconds before closing the plugin, and there was no crash.  However, I have since been unable to reproduce the crash, so am a bit puzzled.  I had a crash yesterday, which I accidentally failed to obtain the evidence, but am pretty sure the circumstances were the same.

I'm leaving the NULL tests out for the time being.


Reproducible: Sometimes

Steps to Reproduce:
Open KMM, open the CSV Plugin, then immediately close it.

Actual Results:  
A crash occurs.

Expected Results:  
No crash occurs.
Comment 1 Fernando Vilas 2011-01-02 19:12:09 UTC
In C++, it is always safe to delete a null pointer. The crash would be caused by something else, like trying to delete memory that had already been deleted.
Comment 2 allan 2011-01-02 19:43:10 UTC
(In reply to comment #1)
> In C++, it is always safe to delete a null pointer. The crash would be caused
> by something else, like trying to delete memory that had already been deleted.

Ah, thanks, Fernando.  I was just about to look more closely at what was going on.  It did seem a bit odd to need to do that.
Comment 3 Thomas Baumgart 2011-01-08 09:12:38 UTC
Looks like you get caught by the Qt object hierarchy which takes care of deleting objects. If you setup a correct parent/children relationship you should not have to worry about the destruction of the widgets.
Comment 4 Cristian OneČ› 2011-05-06 17:04:00 UTC
This is fix as far as I remember.
Comment 5 allan 2011-05-06 17:50:56 UTC
(In reply to comment #4)
> This is fix as far as I remember.

I think so, too, but should have specifically documented it.  The code is now much changed.