Menu

#26 Invalid pointer operation in Project Options

Retest
closed-fixed
nobody
None
2
2017-04-02
2017-02-08
No

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;

Discussion

  • Thomas Mueller

    Thomas Mueller - 2017-02-08

    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.

    screenshot of Delphi IDE Explorer

     

    Last edit: Thomas Mueller 2017-02-08
  • Dean Mustakinov

    Dean Mustakinov - 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.

     
  • Thomas Mueller

    Thomas Mueller - 2017-02-26

    I think I have fixed this problem. Please test the current sources and let me know, since I still cannot reproduce it.

     
  • Dean Mustakinov

    Dean Mustakinov - 2017-03-05

    I have compiled the new version and the invalid pointer error is no longer occuring when changing targets in project options window.

     
  • Achim Kalwa

    Achim Kalwa - 2017-03-13

    Thomas, I'm sorry to say that the bug is not fixed.
    Here are my steps to reproduce the problem:

    • Start Delphi ;-)
    • File / New / VCL Forms Application
    • in the Project Manager, right-click "Target Platforms" and add a new platform: 64 Bit Windows.
    • open the Project options (Ctrl+Shift+F11, or use the menu Project / Options)
    • In the "Target" ComboBox at the dialog's top, select "All configurations - All platforms"

    Boom.
    Invalid pointer operation

    Here is my fix:

    :::delphi
    procedure TManagedForm.SetComboDropDownCount(Control: TControl);
    begin
      if StrContains('Combo', Control.ClassName) or StrContains('ColorBox', Control.ClassName)
      then begin
        // Fix issue #26:
        // Exclude some controls from being changed:
        if (Control is TCustomComboBox)
        or SameText(Control.Name, 'cbPlatformConfigurations')
        or (SameText(Control.Name, 'cbConfig') and
            SameText(Control.ClassName, 'TTargetsComboBox')) 
        then Exit;
      ...
      ...
    

    Achim

     

    Last edit: Achim Kalwa 2017-03-13
    • Thomas Mueller

      Thomas Mueller - 2017-03-17

      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
      • Achim Kalwa

        Achim Kalwa - 2017-03-18

        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

         
  • Thomas Mueller

    Thomas Mueller - 2017-03-17

    I have just committed a modified version of Achim's fix. Could everybody please test again whether this fixes the problem?

     
  • Kerry Sanders

    Kerry Sanders - 2017-03-17

    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
  • Achim Kalwa

    Achim Kalwa - 2017-03-19

    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:

        // Fix issue #26:
        // Exclude some controls from being changed:
        if (Control is TCustomComboBox)
          and (
          SameText(Control.ClassName, 'TTargetsComboBox')
    //      or SameText(Control.Name, 'cbPlatformConfigurations')
          or SameText(Control.Name, 'cbConfig')
          ) then begin
          Exit;
        end;
        if  (Control is TCustomComboBoxEx)
        and SameText(Control.Name, 'cbPlatformConfigurations')
        then Exit;
    
     

    Last edit: Achim Kalwa 2017-03-19
  • Thomas Mueller

    Thomas Mueller - 2017-04-02
    • status: open --> closed-fixed
    • Group: New --> Retest
     

Log in to post a comment.

MongoDB Logo MongoDB