Bugfix for MyListCtrl::OnGetItemAttr
Posted: Thu Sep 10, 2009 9:36 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.
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.
ERROR: vector trans_ was cleared by initVirtualListControl()!
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
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_;
}