Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - [solved] ResetContent and heap corruption
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[solved] ResetContent and heap corruption

 Post Reply Post Reply
Author
Message
BobC View Drop Down
Groupie
Groupie


Joined: 28 April 2017
Location: Longmont, CO
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobC Quote  Post ReplyReply Direct Link To This Post Topic: [solved] ResetContent and heap corruption
    Posted: 13 February 2018 at 9:08pm
RE: Xtreme Toolkit Pro version 18.2.0 running on Windows 10 Pro, Visual Studio 2017, version 15.5.6

I use multiple report controls in an application for tracking stock market trades. One of those controls is an account list that allows the user to edit an account value. When the value is saved, the current report control is updated, and related UI components are sent a message about the update so they can do whatever they need to do, and in some cases, that means refreshing the contents of another report control that is currently out of view of the user.

I have found that after 3-4 account value updates, one of the other report controls crashes with a heap corruption error when calling ResetContent(). I have not been able yet to track down what's going wrong, so I thought I would put this out there and ask for help. It is not likely a threading issue because all of the action occurs in the UI thread.

Here is what the call stack looks like from the ResetContent call:


Back to Top
BobC View Drop Down
Groupie
Groupie


Joined: 28 April 2017
Location: Longmont, CO
Status: Offline
Points: 55
Post Options Post Options   Thanks (1) Thanks(1)   Quote BobC Quote  Post ReplyReply Direct Link To This Post Posted: 22 March 2018 at 4:43pm
I had set this problem aside for awhile, but came back to it today, and figured out what was wrong.

I subclass CXTPReportRecord in places, and in two calls to CXTPReportControl::AddRecord(), I was using new() with the base class instead of my derived class.  That is, I was doing this:

CNoteRow* pRecord = static_cast<CNoteRow*>(m_repNotes.AddRecord(new CXTPReportRecord()));

but should have been doing this:

CNoteRow* pRecord = static_cast<CNoteRow*>(m_repNotes.AddRecord(new CNoteRow()));

I was doing it correctly in most other places, but I guess my brain stalled when writing the broken code.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.109 seconds.