Bugfix for MyListCtrl::OnGetItemAttr

Money Manager Ex Development related posts for both Android and Desktop

Moderator: Renato

Post Reply
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Bugfix for MyListCtrl::OnGetItemAttr

Post by Vadim »

Hi,
I have fixed a bug in mmcheckingpanel.cpp, MyListCtrl::OnGetItemAttr. This bug happens when OnDeleteTransaction(wxCommandEvent& event) called.

Sequence of actions:
1.You confirms deleting transaction.
2.When transaction deleted, mmCheckingPanel::initVirtualListControl() called.

Code: Select all

void mmCheckingPanel::initVirtualListControl()
{
    // clear everything
    trans_.clear(); // CLEARED!!!
#if defined (__WXMSW__)
    wxProgressDialog* pgd = new wxProgressDialog(_("Please Wait"), 
        _("Accessing Database"), 100, this, 
        wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH );

    pgd->Update(10); // TRYING TO UPDATE PRORGESS CAUSES BUG!
    ...
#endif
3. pgd->Update(10) will cause to execute MyListCtrl::OnGetItemAttr(long item) const;
This is update of the progress bar ,10%. Look at code of this function.

Code: Select all

wxListItemAttr* MyListCtrl::OnGetItemAttr(long item) const
{
    /* Returns the alternating background pattern */
    if (cp_->trans_[item]->date_ > wxDateTime::Now()) // trans_ is empty, ACCESS VIOLATION!!!
    {
        return item % 2 ? (wxListItemAttr *)&attr3_ : (wxListItemAttr *)&attr4_;
    }
    return item % 2 ? (wxListItemAttr *)&attr1_ : (wxListItemAttr *)&attr2_;
}
ERROR: vector trans_ was cleared by initVirtualListControl()!
Attachments
diff.zip
(2.47 KiB) Downloaded 495 times
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: Bugfix for MyListCtrl::OnGetItemAttr

Post by Vadim »

Patch commited, revision 411.
Post Reply