Old 04-26-2016, 12:23 AM   #1
Human being with feelings
ijijn's Avatar
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 479
Default JSFX: unusual behaviour using gfx_setimgdim


I've noticed some exceedingly strange behaviour (possibly) related to gfx_setimgdim.

Here's some code I use to resize an image, based on various properties, along with the positive/negative results I'm getting:

// the following code works completely fine...

source = this.getImageSource();
width = this.getWidth();
height = this.getHeight();
gfx_setimgdim(source, width, height);

// as does this...

function setImageDimensions(source, width, height) (
  gfx_setimgdim(source, width, height);

setImageDimensions(this.getImageSource(), this.getWidth(), this.getHeight());

// but this one (sometimes) doesn't...

gfx_setimgdim(this.getImageSource(), this.getWidth(), this.getHeight());
As you can see, the input values are being calculated correctly but sometimes they don't make it through the function call. In particular, I've noticed these two bizarre behaviours at various times:
  1. the result of the first "this"-based calculation is also piped into all other this.xxx values: e.g. a non-"this" source followed by a "this" width also sets the height to this width, with little regard for their actual values, or
  2. all such values are sent as 0
I haven't been able to replicate this behaviour consistently in isolated tests, so maybe it's something to do with concurrency issues during the long evaluation time of arguments, something silly that I'm doing (always a danger) and/or maybe some stack wobbliness? These getter functions involve a few layers of nesting and some fairly hefty string manipulation.

I'm using the wrapped function technique to solve the problem but this does seem weird, right?

Any ideas?
ijijn is offline   Reply With Quote
Old 05-03-2016, 05:13 PM   #2
Human being with feelings
ijijn's Avatar
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 479

Oops, never mind, I worked it out. Some of the strings within my code were being "hive-minded" through the multi-argument phase of gfx_setimgdim's execution, with interesting and unintended results.
ijijn is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 06:35 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.