TMSFNCGrid issue with BLOB content


I am having problems with TMSFNCGrid when I try to display records with BLOB fields (mainly PDF, DOCX and EML files).

The grid uses the TMSFNCGridDatasetAdaptor to display the dataset data. All Grid and Adaptors properties are unchanged (using default values).

On my dataset, when my BLOB field is set to "Visible = False", the grid displays the data correctly.

When my BLOB field is configured on "Visible = True", the grid enters an endless loop and all my program is frozen.

I use MadExcept to identify any freezing of the program. Here is the MadExcept call stack:

As you can see, process is stuck on the UnicodeTagStrip.
Is there something we can do ?

Kind regards,

By default, the grid will try to load content for each table as a string. When the field is a blob stream, the content will be loaded and displayed. Images for example can then be displayed. For other types of data such as the ones you are using, there is no implementation. The best thing to do in that case is to override the OnGetCellData and return an empty string, or a default text.

I understand that values are displayed as string, this make sense, but I don't understand why this is blocking the application.

Using DBeawer tools to query records takes about 238ms.
There must be clearly a defect in the code you are using to display the text.

Could you please have a look at this?

We are going to need a sample file then, so we can check where the issue lies. Without a sample it's hard to reproduce

I'll provide you a reproducible project with anomized data.

I'm using TAureliusDataset, connected to a mariaDB database.

I can send you DDL + table export in SQL format so that you will be able to inject into your DB.

Please find attached a sample project that replicate the issue.
In the IDE :

  • double click the FDConnection and select the TestDb:DB SQLite database.
  • activate FdQuery

IDE will be stuck ....

Project link

The issue still remains that when the blob field is not an image, it will try to load and represent it as a string. I noticed the first blob field is a PDF. When loading PDF content in the text cell, it will detected as HTML and therefore try to render it as HTML. In HTML there are a loops trying to determine the end of a tag. This is where the code loops indefinitely. There are a couple of workarounds:

  1. Implement the OnGetText event on the field and override the text.
  2. Use the OnGetCellProperties and turn off HTML parsing for that specific column
procedure TForm1.TMSFNCGrid1GetCellProperties(Sender: TObject; ACol,
  ARow: Integer; Cell: TTMSFNCGridCell);
  if ACol = 1 then
    Cell.DisplayHTMLFormatting := True;

Thank you Pieter for your fast and valuable feedback. Your solution fixes this current issue but I think it is only a workaround. I don't want to be offensive but I'm convinced that it is a bad idea to let the grid decide to display text, image or render HTML:

  • It's not really optimal for dynamically retrieved data (blod fields or some strings don't always have the same positions)
  • nor for grid design with static fields from the IDE (look at my example, it is necessary to kill the IDE)
  • finally, it doesn't match/mimic behavior of other grids

I would suggest you to modify this behavior and maybe introduce a type of rendering per field/cell. The default would of course be raw text.

Kind regards,

Unfortunately we cannot change the default behavior right now because of backwards compatibility. If we change to not support HTML other cells with HTML text will not be rendered correctly and support will be flooded. However, I completely understand the issue that blob-fields are not supposed to be rendered as HTML text and we'll search for a proper built-in solution without breaking the backwards compatibility.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.