Page 1 of 1

Access violations from TeeChart7.ocx

Posted: Fri Jan 18, 2008 1:06 pm
by 9534357
When i run my application with many Teechart (10) and data and title on chart is changed by time. I got:
"Access violation at address 504D8251 in module 'TeeChart7.ocx'. Read of address 0000000."
To do live data on chart, i use:
+ m_TeeChart.GetAxis().GetBottom().SetMinMax: to move time on chart
+ m_TeeChart.GetHeader().SetCaption: update title on chart
When i only run with 1 or 2 chart, it is OK. But i run about 10 chart, it throw exception.
Is there a mechanism to trap the error with a try ... catch or get a message from the ocx as to what went wrong?

Posted: Fri Jan 18, 2008 2:36 pm
by narcis
Hello Tuan Nguyen,

Are you using latest TeeChart Pro v7 ActiveX available at the client area, which is v7.0.1.4?

If the problem persists, could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Sat Jan 19, 2008 3:16 pm
by 9534357
Hi Narcís

I'm using TeeChart Pro v7 ActiveX v7.0.1.4. I detected the big problem on Tee Chart:
+ Step1: use your [Add data arrays] demo for VC and add some chart on it.
+ Step2: assign name for these chart.
+ Step3: run application, the application is crash with exception: "Unhandled exception in VCTeeChart5.exe: 0xC0000005: Access Violation."

It is urgent problem. I'm looking to forward your feedback.

Best regard,
Tuan Nguyen

Posted: Tue Jan 22, 2008 2:51 pm
by narcis
Hi Tuan Nguyen,

It's strange because this is working fine here using v7.0.1.4. Could you please uninstall your current v7 installation, download v7.0.1.4 from the download area, install it to make sure you are using the latest version available at the client area and check if the problem persists?

Thanks in advance.

Posted: Wed Jan 23, 2008 5:30 pm
by 9534357
Hi Narcís,

Thank you very much for your supports.
I detected my problem, because i don't synchronize between 2 thread: fill data to chart and draw data on chart.

However, i still has a problem with chart. Chart is flicker when i do the following step:
+ Create 1 thread to process the following function:

Code: Select all

void CMulti_ChartDlg::Run()
{
	double dbMin = 0;
	double dbMax = 100;
	CString szLog = _T("");
	for (int i = 0; i < 10000; i++)
	{		
		//fill data into chart
		double dbValueX = dbMin;
		m_TeeChart1.Series(0).Clear();
		for (int i =0 ; i < 10; i++)
		{		
			dbValueX++;
			m_TeeChart1.Series(0).AddXY(dbValueX, 0, _T(""), 0);	
		}
		Sleep(100);
		//display data on chart
		dbMin++;
 		dbMax++;
		m_TeeChart1.GetAxis().GetBottom().SetMinMax(dbMin, dbMax);	
		szLog.Format(_T("From: %g To: %g"), dbMin, dbMax);
		//update title on chart
		m_TeeChart1.GetHeader().SetCaption(szLog);		
	}
}
Please give me some ideas to fix the problem.

Best regards,
Tuan Nguyen

Posted: Thu Jan 24, 2008 11:48 am
by 9534357
Hi Narcís,

With above my code, when i run with long time, Teechart throw exception:"Access violation at address 504D8251 in module 'TeeChart7.ocx'. Read of address 0000000.". It is urgent problem.
I'm looking forward to your answer.

Best regard,
Tuan Nguyen

Posted: Mon Jan 28, 2008 2:42 pm
by narcis
Hi Tuan,

Thanks for the information. Can you reproduce the problem without using threads or using timers instead?

If the problem persits could you please send us a simple example project we can run "as-is" to reproduce the problem here? You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Tue Jan 29, 2008 2:31 am
by 9534357
Hi Narcís,

The problem doesn't happen without using threads or using timers. I update [Multi_Chart.zip] file on your server, please investigate it. Current, our customer is very urgent about the problem. We need some explain about it as soon as possible.

Best regards,
Tuan Nguyen

Posted: Fri Feb 01, 2008 3:28 pm
by Pep
Hi Tuan,

we've been checking this issue, and we've seen the TeeChart multi-threading department is not resilient to VC++ multi-threading.
For the moment we've found some tricks which make the problem to appear not so often (see the code below).

We still investigating it to try to find a good solution to make the problem disappears.

Could you please check if using the following code tricks (basically make use of the AutoRepaint method, and disable the mouse events for the Chart object) help you ?

Code: Select all

void CMulti_ChartDlg::OnOK() 
{
	//Run();	
	m_TeeChart1.SetEnabled(false);
	AfxBeginThread(WorkerThreadProc1, this, THREAD_PRIORITY_NORMAL,0,0,NULL);
	Sleep(5);
	//AfxBeginThread(WorkerThreadProc2, this, THREAD_PRIORITY_NORMAL,0,0,NULL);	
}

void CMulti_ChartDlg::Run()
{
	double dbMin = 0;
	double dbMax = 100;
	CString szLog = _T("");

	for (int i = 0; i < 10000; i++)
	{		
		m_TeeChart1.SetAutoRepaint(false);

		//m_TeeChart1.SetAutoRepaint(false);
		//fill data into chart
		double dbValueX = dbMin;
		
		DWORD numElements[] = {12};
		COleSafeArray p_pArrXValues;
		COleSafeArray p_pArrYValues;
		p_pArrXValues.Create(VT_R8, 1, numElements);	
		p_pArrYValues.Create(VT_R8, 1, numElements);			
		long lIndex = -1;

		for (int i = 0 ; i < 10; i++)
		{		
			
			lIndex++;
			dbValueX++;
			p_pArrXValues.PutElement(&lIndex, &dbValueX);
			p_pArrYValues.PutElement(&lIndex, &dbValueX);			
		}
		m_TeeChart1.Series(0).Clear();
		m_TeeChart1.Series(0).AddArray(p_pArrYValues.GetOneDimSize(), p_pArrYValues, p_pArrXValues);
		//m_TeeChart1.SetAutoRepaint(true);
//		m_TeeChart1.SetAutoRepaint(false);
		Sleep(100);
		//display data on chart
		dbMin++;
 		dbMax++;
		m_TeeChart1.GetAxis().GetBottom().SetMinMax(dbMin, dbMax);	
		szLog.Format(_T("From: %g To: %g"), dbMin, dbMax);
		//update title on chart
		m_TeeChart1.GetHeader().SetCaption(szLog);		

		m_TeeChart1.SetAutoRepaint(true);	
		m_TeeChart1.Repaint();
		
	}

}

Posted: Mon Feb 04, 2008 3:53 am
by 9534357
Hi Pep,

Thank you very much for your efforts.
We try with your code tricks. It is better old code, but problem about [Throw exception:"Access violation at address 504D8251 in module 'TeeChart7.ocx'. Read of address 0000000."] continue happening. Do you show me how to close error message: "Access violation at address 504D8251 in module 'TeeChart7.ocx'. Read of address 0000000.". It won't display in my application. Today, we will send new release for customer. Could you feedback for me today?

Best regards,
Tuan Nguyen

Posted: Tue Feb 05, 2008 12:32 pm
by Pep
The problem appears to occur because the Chart is created on the form and modified in the thread. If it were possible to modify the Chart contents in the form and not via thread (tested here - though intercepting/interrupting a running Chart would become a challenge), or create the Chart dynamically in the thread (not tested) then the problem shouldn't occur.

Posted: Tue Feb 12, 2008 4:11 am
by 9534357
Do you show how to create the Chart dynamically in application? I found 1 thread [http://www.teechart.net/support/viewtopic.php?t=5173] about it, but i can't find "Create ActiveX TChart component at Runtime on MFC app (Form)" subject. Can you show for me about it?

Posted: Tue Feb 12, 2008 10:59 am
by narcis
Hi Tuan,

I have forwarded you the example in the attachments newsgroup.