Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

DataWindow data are corrupted when original buffer is assigned to current buffer – PB Docs 2022 – PowerBuilder Library

DataWindow data are corrupted when original buffer is assigned to current buffer – PB Docs 2022

DataWindow data are corrupted when original buffer is assigned to
current buffer

Symptom

You can get corrupted data if you directly assign the DataWindow
values that were initially retrieved from the database (e.g.
dwcontrol.Object.Data.Primary.Original) to the current values in the
DataWindow control (e.g. dwcontrol.Object.Data.Primary.Current)

Environment

PowerBuilder

Reproducing the Issue

  1. Unzip the repro.zip
    file

  2. Run the application

  3. Select menu File > New > Untitled for Sheet1

  4. Scroll to the end of the result set of the the DataWindow
    control belonging to first tabpage

  5. Switch back and forth several times between second tabpage and
    first tabpage to display corrupted data

    tr_017.png

Cause

  • Expressions like dwcontrol.Object.Data.Primary.Original on the
    right hand side create an array with content pointing to data in the
    DataWindow itself. This means that the data in the array is not
    owned by the array itself but by the DataWindow. This was
    implemented as is since very old versions of PowerBuilder (e.g PB
    6.x). It works with no problem when the DataWindow data are numeric
    but may fail for allocated data like strings. Strings are shared and
    not copied. When you assign values to same DataWindow primary
    buffer, data overlap. Assignment causes de-allocation of old data.
    So the right hand side array may contain de-allocated string memory
    causing the funny characters.

  • This is not a problem when the right hand side and left hand
    side are not the same buffer or even the same DataWindow.

Solution

Use an intermediate temporary variable of type any to pass the
data from one source to another. For example:

Attachment: repro.zip,
dw_main.srd,
dw_nested.srd


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x