Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPReportControl Access Violation
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPReportControl Access Violation

 Post Reply Post Reply
Author
Message
lajbr View Drop Down
Newbie
Newbie


Joined: 20 April 2005
Location: Czech Republic
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote lajbr Quote  Post ReplyReply Direct Link To This Post Topic: CXTPReportControl Access Violation
    Posted: 13 May 2007 at 5:46am
Hi,

I wrote already that I use CXTPReportControl in my e-mail client to the representation of the e-mail storage. Try to imagine e-mail client similar like example GUI Outlook but with the list of e-mails in this control. I use only one class (because of saving memory space), so when the e-mail folder in the treeview is changed then I clear the previous content, load a new one and draw them by Populate(). The trouble is, that several times I have seen an first-chance exception during loading of the list (after application startup) or during fast switching among directories, when I work with this control very hard (all mentioned operation are done very fast in the sequence).
I have a problem with Access violation:
 First-chance exception at 0x00a03763 in ttt.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00a03763 in ttt.exe: 0xC0000005: Access violation reading location 0x00000000.
When I debug this problem in VS2005 the problems occurs in xtpreportcontrol.cpp Line 908 because nRowCount (Line 877) has previous not zero value e.g. 1000 (int nRowCount = m_pRows->GetCount();) but
CXTPReportRow* pRow = m_pRows->GetAt(i); is NULL and there is no check for validity of pRow but it's directly use at this line and the problem is happend...

Lajbr
Back to Top
lajbr View Drop Down
Newbie
Newbie


Joined: 20 April 2005
Location: Czech Republic
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote lajbr Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2007 at 5:49am
I forgot mentioned that this happend in CodeJock 10.4.2.

Lajbr

Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 14 May 2007 at 5:31pm
Hi,

I will add NULL validation here, but this is strange and unexpected error.
 
It looks for me like you work with Report control from different threads: while working thread populating control -- the main thread redraws it. Is it correct? If so, note that Report is not a multi-threaded control - there are no locks inside. You have to add a critical section and enter it before and using control. Or add some other thread synchronization mechanism by yourself.

--
WBR,
Serge
Back to Top
lajbr View Drop Down
Newbie
Newbie


Joined: 20 April 2005
Location: Czech Republic
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote lajbr Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 2007 at 12:59am
Hi,

yes you are right, because if you load an e-mail folder with e.g. 5000 e-mails or more, then you cannot do it in the main thread... So the loading of content is running in the different thread which is started only for load and the other operation works in the main thread. I suppose that you are right that this is the problem and I solve this synchronization, on the other hand I saw yesterday simmilar problem when the load was started and I move with the mouse, it crash in something (i don't know it directly) which is common with ToolTip text in CXTPReportControl or CXTPReportControlRow. But this is type of operation, which I cannot influence...

Lajbr
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 2007 at 1:11am
Hello,
 
I think you need receive emails in thread and then send message to main thread to repopulate report.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
lajbr View Drop Down
Newbie
Newbie


Joined: 20 April 2005
Location: Czech Republic
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote lajbr Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 2007 at 11:06am
Hi Oleg,

thank for your advice but that's nearly what I'm doing. In the thread I read e-mails from the disk and add them by AddRecord() to the CXTPReportControl or receive & send to the server (add or remove records) in the similar way. When the operation is succesfully done then I call Populate() to the control for ensuring the correct folder content. But I'm doing this Populate in the working thread. I think that doesn't matter if I'm doing the filling and repainting of the CXTPReportControl content in the same thread or in two separate threads. I think the 1st solution is maybe more safety. If the new folder content is required during filling or repaiting of the CXTPReportControl, then I set the sign for skip the previous thread and I'm waiting with WaitForSingleObject() till the first one thread finish. I consult this with my college and I think that it's safe enough for ensure correct thread synchronization and correct thread behaviour. Do you think that there is something wrong?

Lajbr
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 2007 at 5:45am
Hi,
you have call Populate  in main thread.  See our Grep sample - it create records in work thread but call Populate in main.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
lajbr View Drop Down
Newbie
Newbie


Joined: 20 April 2005
Location: Czech Republic
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote lajbr Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2007 at 9:28am
Hi Oleg,

thanks for your reply. It works now. I used a little different access than it's used in Grep sample but with the same idea. The problem was in collision between AddRecord() and Populate(). After synchronization of these problematic operations it works fine.

Lajbr
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.172 seconds.