![]() | Steema Issues DatabaseNote: 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. |
| Summary: | C++ AV when a TChartListBox is used inside a DLL | ||
|---|---|---|---|
| Product: | VCL TeeChart | Reporter: | david berneda <david> |
| Component: | Canvas | Assignee: | Steema Issue Manager <issuemanager> |
| Status: | IN_PROGRESS --- | ||
| Severity: | normal | CC: | narcis, yeray |
| Priority: | Normal | ||
| Version: | 131119 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows | ||
| URL: | http://www.teechart.net/support/viewtopic.php?f=3&t=14519 | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
| Attachments: | XE4 C++ project to reproduce DLL AV | ||
|
Description
david berneda
2013-12-19 04:16:40 EST
Created attachment 60 [details]
XE4 C++ project to reproduce DLL AV
Tested with XE5 Update 2, cannot reproduce the AV. 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);
....
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.
|