Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OvcDbtbl table combobox painting raise AV #39

Open
xCMNx opened this issue Mar 7, 2023 · 1 comment
Open

OvcDbtbl table combobox painting raise AV #39

xCMNx opened this issue Mar 7, 2023 · 1 comment

Comments

@xCMNx
Copy link

xCMNx commented Mar 7, 2023

The problem could be that we allocate PString for TOvcTCComboBox data in tryGetMem, that is the first part of problem.
In tryGetMem we need to check type of cell to use GetMem insteed New(PString), tryFreeMem need to fix too

  ///TOvcTCComboBox data is not just a PString
  if ((ACell is TOvcTCString) or (AField.DataType in [ftString, ftWideString])) and not (ACell is TOvcTCComboBox) then
    New(PString(P))
  else
    GetMem(P, Size);

The second part is tbGetFieldValue we use allocated PString like a TCellComboBoxInfo

     end else begin
        /// looks OK if we use new(PString) in tryGetMem
        PString(Data)^ := AField.Text;
        /// still OK
        if PString(Data)^ = '' then
          Idx := -1
        else
          Idx := TOvcTCComboBox(ACell).Items.IndexOf(PString(Data)^);

        /// we just damaged a string data, it stil not so critical
        PCellComboBoxInfo(Data)^.Index := Idx;

        if Idx = -1 then
          if TOvcTCComboBox(ACell).Style in [csDropDown, csSimple] then
            /// and now we try to store our damaged string into what?
            PCellComboBoxInfo(Data)^.St := PString(Data)^ //S;

It works if change it to

     end else begin
        if AField.Text = '' then
          Idx := -1
        else
          Idx := TOvcTCComboBox(ACell).Items.IndexOf(AField.Text);

        PCellComboBoxInfo(Data)^.Index := Idx;

        if Idx = -1 then
          if TOvcTCComboBox(ACell).Style in [csDropDown, csSimple] then
            PCellComboBoxInfo(Data)^.St := AField.Text;
@romankassebaum
Copy link
Contributor

I hope that I understood you correctly. Please check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants