- This topic has 8 replies, 3 voices, and was last updated 7 years, 4 months ago by Support.
-
AuthorPosts
-
March 7, 2017 at 4:12 pm #37376WhookieParticipant
Hi,
in a new project I'm just using TsAlphaImageList and I quite often get an exception in class $C0000005 with message c0000005 ACCESS_VIOLATION as soon as an image should be drawn.
The debugger stops in sGraphUtils.CreateContributors at the following code:
Code:with Data[Count] do begin
if B < 0 then
Pixel := -B
else
if B >= MaxSize then
Pixel := 2 * MaxSize – B – 1 <-----Exception
else
Pixel := B;Pixel := Pixel * Delta;
Weight := Round(W * Scale2 * 65536);
end;This might be due to suspicious code in sGraphUtils.CreateContributors:
1.
Code:…
CSize := Trunc(AWidth * 2 + 1) * SizeOf(TContributor);
GetMem(Contrib, Size * (SizeOf(TCList) + CSize));This might or might not allocate enough memory because of the 'AWidth * 2 + 1' term.
2.
Code:…
Contrib[A].Data := Data;
Data := PContributorList(DWord(Data) + DWord(CSize));
=====This is definitly a bug and will (or will not) lead to an error depending on where the current memory-block is physically mapped.
I haven't used AlphaControls for quite some time, so I hope you are focused on the project and the 64bit migration (don't know if the code is full of bugs like this, because I just dropped in the image list)!
In general:
Stay away from hard-casts as much as possible, use NativeInt/NativeUInt with pointer arithmentics (or PByte+Inc()).
Stay away from PAnsiChar (for anything except AnsiChars).
Use FastMM4 while testing and define AlwaysAllocateTopDown this will raise errors for most of such bugs.
Also look through message-handling code and make sure you use THandle/LPARAM/WPARAM.
March 12, 2017 at 7:16 pm #56315SupportKeymasterThank you for the message. I will check and I will try to improve it.
If you have a test-application with error and you can share it, this would be great.
March 13, 2017 at 9:55 am #56319WhookieParticipant'Support' wrote:Thank you for the message. I will check and I will try to improve it.
If you have a test-application with error and you can share it, this would be great.
It is a rather big project and I'm on a tight schedule so maybe next month.
To fix my problem do at least the following:
Code:…
Contrib[A].Data := Data;
Data := PContributorList(NativeUInt(Data) + DWord(CSize));
==========March 13, 2017 at 10:31 am #56320SupportKeymasterI have changed it to this:
Code:…
Contrib[A].Data := Data;
Data := PContributorList(PAnsiChar(Data) + CSize);What you think about the “PAnsiChar” in this case?
March 18, 2017 at 1:59 pm #56328WhookieParticipant'Support' wrote:What you think about the “PAnsiChar” in this case?
This will work since you are using a pointer type now.
I think you have some backward compatibility issues to take into account (D2007 and lower?) so it's sort of a good compromise (otherwise I would use
Code:Data := PContributorList(PByte(Data) + CSize);instead).
BTW it would be really great to have a selectable background color in the Imagelist window (as I'm working with styles I always have lists with pure white icons and they are invisible)!
March 22, 2017 at 12:54 pm #56340SupportKeymaster'Whookie' wrote:BTW it would be really great to have a selectable background color in the Imagelist window (as I'm working with styles I always have lists with pure white icons and they are invisible)!I will try to do it in the v12.03
July 18, 2017 at 2:40 pm #56917WhookieParticipant'Support' wrote:I will try to do it in the v12.03
Hi, I went to the current version (12.12) and found that you have
* Added support of the BkColor property in the TsAlphaImageList component
in 12.03 but it seems as it isn't what I was after.
So I thought a show you a screenshot of what I'm struggling with:
[attachment=8388:imagelist_win.jpg]
The mouse hovers over image 5 (cursor not shown) so this is the only way to see what image is stored there.
What I meant was something like this:
[attachment=8392:imglst_bk.JPG]
I hacked that into your dialog and attached that project too (you need to remove “.pas” though and unpack it).
July 18, 2017 at 3:01 pm #56918Stephane SenecalParticipantI think it was a typo. I'm quite sure he meant 12.13 since that's the number of the next version.
Stephane Senecal
CIS Group
Delphi programmer since 2001July 21, 2017 at 3:50 am #56928SupportKeymasterHello, Whookie
I think, you need a possibility to change a color of icons background in this dialog. Right?
I can add such ColorSelector there.
-
AuthorPosts
- You must be logged in to reply to this topic.