Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 522 - C++ AV when a TChartListBox is used inside a DLL
Summary: C++ AV when a TChartListBox is used inside a DLL
Status: IN_PROGRESS
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 131119
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Steema Issue Manager
URL: http://www.teechart.net/support/viewt...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-19 04:16 EST by david berneda
Modified: 2014-10-30 16:47 EDT (History)
2 users (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments
XE4 C++ project to reproduce DLL AV (85.50 KB, application/x-zip-compressed)
2013-12-19 04:18 EST, david berneda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description david berneda 2013-12-19 04:16:40 EST
Run attached C++ XE4 project, an AV is raised in DLL process.

Suspecting the problem is related to including TeeGDIPlus unit (but not using it) in the dll.

See complete description at url Steema forums topic.
Comment 1 david berneda 2013-12-19 04:18:35 EST
Created attachment 60 [details]
XE4 C++ project to reproduce DLL AV
Comment 2 david berneda 2014-01-15 10:06:50 EST
Tested with XE5 Update 2, cannot reproduce the AV.
Comment 5 david berneda 2014-10-28 12:29:05 EDT
With the latest TeeChart source code (140923) and Studio XE7 C++, it seems its necessary again to initialize Gdiplus in the EXE, like for example:

#include "Winapi.GDIPOBJ.hpp"
#include "Winapi.GDIPAPI.hpp"

//---------------------------------------------------------------------------
USEFORM("UnitEXE1.cpp", FormEXE1);
//---------------------------------------------------------------------------
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
  Gdiplus::GdiplusStartupInput StartupInput;

  StartupInput.DebugEventCallback = 0;
  StartupInput.SuppressBackgroundThread = false;
  StartupInput.SuppressExternalCodecs  = false;
  StartupInput.GdiplusVersion = 1;

  unsigned long gdiplusToken=0;

  Gdiplus::GdiplusStartup(&gdiplusToken, &StartupInput, 0);

	try
	{
		Application->Initialize();
		Application->MainFormOnTaskBar = true;
		Application->CreateForm(__classid(TFormEXE1), &FormEXE1);

....
Comment 6 david berneda 2014-10-30 16:47:13 EDT
I've managed to reproduce the AV issue with clone example projects made in Delphi.

This way I could debug using the Delphi-made TeeChart packages to find the exact source code lines, and I've found a possible fix.

(One DLL using runtime packages, called from an EXE also using runtime packages).

The ideal situation would be an EXE using runtime packages, calling another package instead of a DLL. This would allow using the classes inside the package in a normal way.

The first fix is at TeeGDIPlus.pas unit, at procedure TGDIPlusCanvas.SetCanvas, adding "if IsAvailable then" before calling GetGraphics:

procedure TGDIPlusCanvas.SetCanvas(const ACanvas:TCanvas);
begin
  inherited;

  if IsAvailable then  <------- FIX
     GetGraphics; 

  if Assigned(IXORCanvas) then
     IXORCanvas.ReferenceCanvas:=ACanvas;
end;



Maybe there are more places in TeeGDIPlus unit where this same fix should be applied, I'll keep testing.   This is a very special case that only happens because the code using GDI+ is inside a DLL instead of in a package.