Bugfix for MyListCtrl::OnGetItemAttr

Page 1 of 1
2 posts
Bugfix for MyListCtrl::OnGetItemAttr

Vadim
MMEX Developer

Posts: 142
Joined: Mon Aug 03, 2009 1:35 am
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 259 times
Re: Bugfix for MyListCtrl::OnGetItemAttr

Vadim
MMEX Developer

Posts: 142
Joined: Mon Aug 03, 2009 1:35 am
Patch commited, revision 411.
Page 1 of 1
Who is online

Users browsing this forum: No registered users and 4 guests

cron