access violation in module "Teechart8.ocx"

TeeChart for ActiveX, COM and ASP
Post Reply
knk2
Newbie
Newbie
Posts: 6
Joined: Tue Nov 18, 2008 12:00 am

access violation in module "Teechart8.ocx"

Post by knk2 » Tue Oct 12, 2010 8:53 am

Hello

I use
1. October 2008 TeeChart Pro Activex Control v8 v8.0.0.5 Release
2. Win 7 prof
3. Microsoft VS 2008 C++ Win32 MFC SDI FormView


I receive the message

Access violation at address 04012C1A in module 'TeeChart8.ocx'. Read of adresses 00006ECC.
or
Access violation at address 03DEF7C0 in module 'TeeChart8.ocx'. Read of adresses 00001A88.
and addresses can be different in some limits

It happens sometime only when I restart thread after stop:

Code: Select all


//start and restart with this
wtPlotProc = AfxBeginThread(uiPlotProc,this);


UINT		CContView::uiPlotProc(LPVOID param)
{
	CContView *pdlg = static_cast<CContView *>(param);//pointer on mdi dialog
	if (pdlg == NULL || !pdlg->IsKindOf(RUNTIME_CLASS(CContView)))
		return 1;

              pdlg->m_ctrlChart1.RemoveAllSeries();
	pdlg->m_ctrlChart1.AddSeries(scLine);
	pdlg->m_ctrlChart1.AddSeries(scLine);
	pdlg->m_ctrlChart1.AddSeries(scPoint);
	
	pdlg->m_ctrlChart1.Series(0).SetShowInLegend(false);
	pdlg->m_ctrlChart1.Series(0).SetColor(RGB(0,100,200));
	pdlg->m_ctrlChart1.Series(0).GetAsLine().GetLinePen().SetWidth(1);
	pdlg->m_ctrlChart1.Series(1).SetShowInLegend(false);
	pdlg->m_ctrlChart1.Series(1).SetColor(RGB(200,20,0));
	pdlg->m_ctrlChart1.Series(1).GetAsLine().GetLinePen().SetWidth(2);
	pdlg->m_ctrlChart1.Series(2).SetShowInLegend(false);
	pdlg->m_ctrlChart1.Series(2).SetColor(RGB(20,200,20));
	pdlg->m_ctrlChart1.Series(2).GetAsPoint().GetPointer().SetStyle(psCircle);
	pdlg->m_ctrlChart1.Series(2).GetAsPoint().GetPointer().SetHorizontalSize(3);
	pdlg->m_ctrlChart1.Series(2).GetAsPoint().GetPointer().SetVerticalSize(3);
	pdlg->m_ctrlChart1.Series(2).AddXY(2048,0,"",RGB(20,200,20));

	pdlg->m_ctrlChart1.Series(0).SetName("Series0");

	pdlg->m_ctrlChart1.Series(0).AddArray(iFFTSize,YValues,XValues);
	pdlg->m_ctrlChart1.Series(1).AddArray(iFFTSize,YValues,XValues);

              ....
              CSeries lSeries = pdlg->m_ctrlChart1.Series(0);
              .....
              pdlg->m_ctrlChart1.Repaint();
	pdlg->m_ctrlChart1.Series(0).RefreshSeries();
	pdlg->m_ctrlChart1.Series(2).RefreshSeries();
              ...
              return 0;
}

I don't know where to search for an error
Could you direct me?

Thank you

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: access violation in module "Teechart8.ocx"

Post by Narcís » Wed Oct 13, 2010 8:58 am

Hi knk2,

Can you please check if latest TeeChart Pro v8 ActiveX maintenance release available at the client area solves the problem at your end? If it doesn't, could you please attach a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

knk2
Newbie
Newbie
Posts: 6
Joined: Tue Nov 18, 2008 12:00 am

Re: access violation in module "Teechart8.ocx"

Post by knk2 » Wed Oct 13, 2010 9:51 am

Hello

Are you talk about "TeeChartAX8English.exe March 01, 2010 Build 8.0.0.8" ? Should I use this update?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: access violation in module "Teechart8.ocx"

Post by Narcís » Wed Oct 13, 2010 9:59 am

Hi knk2,

Yes, that's it: Not necessarily the English build though, you can use TeeChart8ActiveX.exe too.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

knk2
Newbie
Newbie
Posts: 6
Joined: Tue Nov 18, 2008 12:00 am

Re: access violation in module "Teechart8.ocx"

Post by knk2 » Wed Oct 13, 2010 11:02 am

I will try to describe as I use teechart in the project.
I catch sometime access violation error in this simple example, when restart thread with OnBnClickedCap192() and OnBnClickedStopcap192() function

Code: Select all

//i have formview class
//---------------- file ContView.h --------------------------------------------------

#pragma once

#include "tchart\tchart.h"

class CContView : public CFormView
{
	DECLARE_DYNCREATE(CContView)

protected:
	CContView();           // protected constructor used by dynamic creation
	virtual ~CContView();

public:
	enum { IDD = IDD_CONTROL_VIEW };

	CTChart		m_ctrlChart1;
	CWinThread	*wtPlotProc;
	static UINT	uiPlotProc(LPVOID param);//plot PSD 4096 poitns
	afx_msg void OnBnClickedCap192();
	afx_msg void OnBnClickedStopcap192();

}


//----------------------- file ContView.cpp ------------------------------------------------
#include "ContView.h"

//tchart include
#include "tchart\TeeChartDefines.h"
#include "tchart\Aspect.h"
#include "tchart\Axis.h"
#include "tchart\Axes.h"
#include "tchart\Areaseries.h"
#include "tchart\Arrowseries.h"
#include "tchart\Axisarrowtool.h"
#include "tchart\Axislabels.h"
#include "tchart\Axistitle.h"
#include "tchart\LineSeries.h"
#include "tchart\Brush.h"
#include "tchart\Canvas.h"
#include "tchart\environment.h"
#include "tchart\Marks.h"
#include "tchart\Pen.h"
#include "tchart\PointSeries.h"
#include "tchart\Pointer.h"
#include "tchart\Scroll.h"
#include "tchart\Series.h"
#include "tchart\Strings.h"
#include "tchart\TeeFunction.h"
#include "tchart\titles.h"
#include "tchart\teefont.h"
#include "tchart\valuelist.h"
#include "tchart\wall.h"
#include "tchart\Zoom.h"
#include "tchart\export.h"
#include "tchart\jpegexport.h"
#include "tchart\gifexport.h"


void CContView::OnInitialUpdate()
{
       m_ctrlChart1.RemoveAllSeries();
	m_ctrlChart1.GetEnvironment().SetMouseWheelScroll(false);
	m_ctrlChart1.GetAspect().SetView3D(false);
	m_ctrlChart1.GetAxis().GetBottom().SetAutomaticMaximum(FALSE);
	m_ctrlChart1.GetAxis().GetBottom().SetAutomaticMinimum(FALSE);
	m_ctrlChart1.GetAxis().GetLeft().SetAutomaticMaximum(TRUE);
	m_ctrlChart1.GetAxis().GetLeft().SetAutomaticMinimum(TRUE);
	m_ctrlChart1.GetAxis().GetBottom().SetMaximum(65000);
	m_ctrlChart1.GetAxis().GetBottom().SetMinimum(-65000);
	m_ctrlChart1.GetAxis().GetLeft().SetMinimum(-130);
	m_ctrlChart1.GetAxis().GetLeft().SetMaximum(0);
}

//start func
void CContView::OnBnClickedCap192()
{	
	if (wtPlotProc==NULL)
		wtPlotProc = AfxBeginThread(uiPlotProc,this);
}

//stop func
void CContView::OnBnClickedStopcap192()
{
	//wait while stoped uiPlotProc
	SetEvent(hPlotEvents[1]);
	if (wtPlotProc!=NULL)
	{
		waitWithMessageLoop(this->wtPlotProc->m_hThread,0);
		wtPlotProc=NULL;
	}
}

//plot thread function
UINT		CContView::uiPlotProc(LPVOID param)
{
	CContView *pdlg = static_cast<CContView *>(param);//pointer on form
	if (pdlg == NULL || !pdlg->IsKindOf(RUNTIME_CLASS(CContView)))
		return 1;   // if pdlg is not valid
	
	ResetEvent(pdlg->hPlotEvents[1]);
	
	int iFFTSize = (4096);
	const double	dHz = 48000/iFFTSize;

	//init variable used for messages loop
	bool	bDone = false;
	DWORD	dwResult,dwResult1,dwResult2,dwResult3;

	//array ------------------------------------------
	COleSafeArray XValues;
  COleSafeArray YValues;
	double		xVal[FFT_SIZ];
	SAFEARRAYBOUND rgsabound[1];
	rgsabound[0].lLbound = 0;
	rgsabound[0].cElements = iFFTSize;
	

	XValues.Clear();YValues.Clear();
	XValues.Create(VT_R8, 1, rgsabound);
	YValues.Create(VT_R8, 1, rgsabound);
	long icur;
	// Initialize them with values...
	for(long index=0; index<iFFTSize; index++) 
	{
		double CV=0;
		double val;
		if (index <iFFTSize/2)
		{
			icur = (index+iFFTSize/2);
			val =(index*dHz);
			xVal[icur]=val;
			XValues.PutElement(&icur, &val);
			YValues.PutElement(&icur, & CV);
		}
		else
		{
			icur = (index-iFFTSize/2);
			val = ((_REAL)(index-iFFTSize)*dHz);
			xVal[icur]=val;
			XValues.PutElement(&icur, &val);
			YValues.PutElement(&icur, & CV);
		}
	};

	pdlg->m_ctrlChart1.RemoveAllSeries();
	pdlg->m_ctrlChart1.AddSeries(scLine);
	pdlg->m_ctrlChart1.AddSeries(scLine);
	pdlg->m_ctrlChart1.AddSeries(scPoint);
	
	pdlg->m_ctrlChart1.Series(0).SetShowInLegend(false);
	pdlg->m_ctrlChart1.Series(0).SetColor(RGB(0,100,200));
	pdlg->m_ctrlChart1.Series(0).GetAsLine().GetLinePen().SetWidth(1);
	pdlg->m_ctrlChart1.Series(1).SetShowInLegend(false);
	pdlg->m_ctrlChart1.Series(1).SetColor(RGB(200,20,0));
	pdlg->m_ctrlChart1.Series(1).GetAsLine().GetLinePen().SetWidth(2);
	pdlg->m_ctrlChart1.Series(2).SetShowInLegend(false);
	pdlg->m_ctrlChart1.Series(2).SetColor(RGB(20,200,20));
	pdlg->m_ctrlChart1.Series(2).GetAsPoint().GetPointer().SetStyle(psCircle);
	pdlg->m_ctrlChart1.Series(2).GetAsPoint().GetPointer().SetHorizontalSize(3);
	pdlg->m_ctrlChart1.Series(2).GetAsPoint().GetPointer().SetVerticalSize(3);
	pdlg->m_ctrlChart1.Series(2).AddXY(2048,0,"",RGB(20,200,20));

	pdlg->m_ctrlChart1.Series(0).SetName("Series0");

	pdlg->m_ctrlChart1.Series(0).AddArray(iFFTSize,YValues,XValues);
	pdlg->m_ctrlChart1.Series(1).AddArray(iFFTSize,YValues,XValues);
	

	pdlg->m_ctrlChart1.GetExport().GetAsGIF().SetColorReduction(rmNetscape);


	pdlg->m_ctrlChart1.GetExport().GetAsGIF().SetDitherMode(dmNearest);
	pdlg->m_ctrlChart1.GetExport().GetAsGIF().SetHeight(444);
	pdlg->m_ctrlChart1.GetExport().GetAsGIF().SetWidth(545);
	pdlg->SendDlgItemMessage(IDC_DIFMASK_ED,WM_SETTEXT,NULL,(LPARAM)"int");
	
	//----------------------------------------
	dwResult2 = WaitForSingleObject(pdlg->hPlotEvents[1],INFINITE);
  if (dwResult2 == (WAIT_OBJECT_0 + 0))
	{
	bDone=true;
	}
              
              return 0;
}

//wait thread exit
BOOL waitWithMessageLoop(HANDLE hEvent, DWORD dwTimeout)
{
 	DWORD dwRet;
	do
	{
		dwRet = ::MsgWaitForMultipleObjects(1, &hEvent, FALSE, INFINITE, QS_ALLINPUT);
		if (dwRet != WAIT_OBJECT_0)
		{
			MSG msg;
			while (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
	} while ((dwRet != WAIT_OBJECT_0) && (dwRet != WAIT_FAILED));
	
	return TRUE;
}

knk2
Newbie
Newbie
Posts: 6
Joined: Tue Nov 18, 2008 12:00 am

Re: access violation in module "Teechart8.ocx"

Post by knk2 » Wed Oct 13, 2010 11:58 am

One question
Should I replace all teechart .cpp and .h files in my project by files from update, or replace only .ocx and .cab files ?

thank you

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: access violation in module "Teechart8.ocx"

Post by Narcís » Fri Oct 15, 2010 8:13 am

Hi knk2,
Should I replace all teechart .cpp and .h files in my project by files from update, or replace only .ocx and .cab files ?
Yes, those files should be updated with each maintenance release.

It would also be very helpful if you tried to arrange a simple example project we can run "as-is" and let us know the exact steps we should follow to reproduce the problem here.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply