Solved TD-23422: (UPD1 regression) SalTreeGetItemData returns wrong value if thedata is negative

Post found bugs and possible workarounds.
Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 74
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

TD-23422: (UPD1 regression) SalTreeGetItemData returns wrong value if thedata is negative

Post by Igor Ivanovic » 09 Mar 2017, 07:23

With the tree that is populated with data values that are both positive and negative, the SalTreeGetItemData returns a large positive value for the negative values.

I've attached a small repro case.
You do not have the required permissions to view the files attached to this post.
Igor Ivanovic
Image

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 275
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: TD-23422: (UPD1 regression) SalTreeGetItemData returns wrong value if thedata is negative

Post by Dave Rabelink » 09 Mar 2017, 08:45

I was afraid of this...

During UPDATE1 beta testing I found Sal/Vis functions returning large numbers instead of the expected negative values.
This has to do with typecasting. Internally the datatypes are changed to be compatible between x86 and x64.
And some typecastings are not correctly set.

Looking at the \inc\centura.h file, this is the interface declaration:

DWORD_PTR CBEXPAPI SalTreeGetItemData(HWND, DWORD_PTR);

A DWORD_PTR is an unsigned datatype.

So TD will cast the item value to unsigned. Meaning negative values will be positive now.

But I have a workaround until Gupta fixes this:

You have to redefine the API declaration in your code. Create a new SalTreeGetItemData2 declaration, but return a LONG now.

Code: Select all

Library name: cdlli70.dll
	Function: SalTreeGetItemData2
		Export Ordinal: 1153
		Returns
			Number: LONG
		Parameters
			Window Handle: HWND
			Number: LONG
This seems to solve the issue.
(beware that this is a temporarily workaround until Gupta has a real fix)

If you find other locations having a similar issue, this workaround could work for those also. Just try it out.

Igor, could you test the workaround to see if that works?

SalTreeGetItemData_Bug_WORKAROUND.zip
You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Igor Ivanovic
Site Admin
Site Admin
Croatia
Posts: 74
Joined: 05 Mar 2017, 12:37
Location: Zagreb, Croatia

Re: TD-23422: (UPD1 regression) SalTreeGetItemData returns wrong value if thedata is negative

Post by Igor Ivanovic » 09 Mar 2017, 09:05

Dave,

Your workaround works!
You saved my day :D :D :D
Igor Ivanovic
Image

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 275
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: TD-23422: (UPD1 regression) SalTreeGetItemData returns wrong value if thedata is negative

Post by Dave Rabelink » 27 Mar 2017, 07:09

I came across a related issue in one project.
There some vis function declarations were not coming from the default vt*.apl but had them copied into the sources.
By changing manually vtixx.dll to vti70.dll, the project compiles and seem to work.

But the return and parameter datatypes were not changed, still having the previous datatype.
At runtime the issue as described here is seen: a large number instead of negative values.

So, when converting to TD70, be really sure to use the correct vis function declarations as in the default vt libraries.
Even better, never copy the vis function declarations into your project sources, but include the default libraries.

This thread is also related to these:

TD-23246: 32 bit TD gets negative number from external function returning HANDLE
TD-23246: TD 7.0 & HANDLE datatype
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Uwe van der Horst
Site Admin
Site Admin
Germany
Posts: 49
Joined: 05 Mar 2017, 14:21
Location: Wetter (Ruhr), Germany

Re: TD-23422: (UPD1 regression) SalTreeGetItemData returns wrong value if thedata is negative

Post by Uwe van der Horst » 08 May 2017, 16:33

Hi Dave,

we are currently upgrading our software from TD-63 to TD-7. Today my QA reported this issue and thanks to this thread I had immediately the solution :D :D :D

Thanks a lot.
Best regards,
Uwe van der Horst
Advo-web GmbH

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 275
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: TD-23422: (UPD1 regression) SalTreeGetItemData returns wrong value if thedata is negative

Post by Dave Rabelink » 12 Jun 2017, 07:16

This defect has been fixed in TD 7.0.2.

When the suggested workaround is applied, please remove it and use the 'official' function.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “Bug Reports”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests