Delphi 10.1 Berlin (possibly other versions as well)
Windows 7, 10
When selecting different Target in Project Options Delphi sometimes reports "invalid pointer operation".
I have traced the issue to procedure TManagedForm.SetComboDropDownCount.
It seems that when combo box is derived from TCustomComboBoxEx changing the DropDownCount will cause invalid pointer operation error when combo box items are cleared.
The workaround is not to change DropDownCount for TCustomComboBoxEx and descendants.
procedure TManagedForm.SetComboDropDownCount(Control: TControl);
begin
** if Control is TCustomComboBoxEx then Exit;**
if StrContains('Combo', Control.ClassName) or StrContains('ColorBox', Control.ClassName) then
begin
if TypInfo.IsPublishedProp(Control, 'DropDownCount') then
if TypInfo.PropIsType(Control, 'DropDownCount', tkInteger) then
if GetPropValue(Control, 'DropDownCount', False) < ComboDropDownCount then
TypInfo.SetPropValue(Control, 'DropDownCount', ComboDropDownCount);
end;
end;
I cannot reproduce this problem. I created a new VCL project in delphi 10.1 Update 2, opened the project options and changed the target combobox very often on various pages. Nothing bad happened.
Also, the target combobox does not descend from TComboboxEx, see picture.
Last edit: Thomas Mueller 2017-02-08
Hi Thomas,
These are the steps that result in invalid pointer operation in my environment:
Creata new VCL project
Save
Right click on Project1.exe in Project Manager
Select Options
Project options window is shown
Target combo box is showing Debug configuration - 32-bit Windows platform
Click on Target combo box and select All Configurations
Error dialog with message "Invalid pointer operation" is shown
Attached file has the stack trace from the error dialog.
The following line that makes me think this is related to TCustomComboBoxEx descendants:
[50B2F75A]{vcl240.bpl } Vcl.ComCtrls.TComboBoxExStrings.Clear (Line 29583, "Vcl.ComCtrls.pas" + 3) + $6
I am running Delphi Berlin with Update 2 on 64bit Windows.
The only other extensions installed are the ones that come with JCL library.
If I uninstall GExperts, "Invalid pointer operation" error does not occur.
If I apply the workaround from the initial post, "Invalid pointer operation" error does not occur.
Let me know if you need any additional information.
I think I have fixed this problem. Please test the current sources and let me know, since I still cannot reproduce it.
I have compiled the new version and the invalid pointer error is no longer occuring when changing targets in project options window.
Thomas, I'm sorry to say that the bug is not fixed.
Here are my steps to reproduce the problem:
Boom.
Invalid pointer operation
Here is my fix:
Achim
Last edit: Achim Kalwa 2017-03-13
Hi Achim,
I followed your steps and still can not reproduce the problem. I take your word for it though and add your fix. Thanks.
Edit:
I just checked it and, no I won't. It disables this feature everywhere. Are you sure you meant to write:
if (Control is TCustomComboBox)
or SameText(Control.Name, 'cbPlatformConfigurations') ?
I think this should be an and followed by a parenthesis around the ther ored conditions.
twm
Last edit: Thomas Mueller 2017-03-17
Hi Thomas,
I'm sorry, that was a copy & paste error. My intention was to exclude TCustomComboBoxEx, or the control named "cbPlatformConfigurations" or "cbConfig". But you got the idea; and your code works fine.
Thanks,
Achim
I have just committed a modified version of Achim's fix. Could everybody please test again whether this fixes the problem?
Since it was mentioned in the original post that possibly other versions could have the problem, I tried the build that I have from code that I pulled on 3/3/2017. I was not able to duplicate this issue in XE7 with that build.
While checking XE7 for this issue, I just found a different error that I can duplicate consistently. It only happens after opening the Project Options. I will pull the latest code and test to see if the latest change fixes this issue also.
Last edit: Kerry Sanders 2017-03-18
This bug is still there. The culprit control is not only 'cbConfig' in the Delphi Projects Option, but cbPlatformConfigurations on other PropertySheet. This is not derived from TCustomComboBox, but from TCustomComboBoxEx. So to exclude this control from beeing touched by GExperts SetComboDropDownCount() the code needs to test for ClassName and the ComponentName. This is what my first code patch should have done.
New attempt as following. To avoid nested if-and-or I've added a new condition:
Last edit: Achim Kalwa 2017-03-19