Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / GetFreeImage function dosent always work??? why!?

Author
Message
haliop
User Banned
Posted: 26th Apr 2010 15:11
i use a simple


this in thoery is good and fast..
but always always stop at 8...
have no clue how to get pass that..
if i put

it goes up to 9 and stuck there...
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 26th Apr 2010 15:55
Are you saying ID 8 has an image assigned to it?, but its not being recognised?

Pehaps you have the file name wrong for image 8, are you sure it is loaded in correctly?

JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 26th Apr 2010 16:27
Where's your return statement? Return fi;

JTK
haliop
User Banned
Posted: 26th Apr 2010 16:39
the return is there i just didnot wrote it here
and yes the images are named correctly not only that
they are created using dbCreateBitmap and all kind of 2D oparations are assigned to them
then with dbGetImage

if i do it 8 times , everything is ok , but when i get over to 9 it remin at 8.. this is wierd
however i found a lame fix for that , which may cause me some problems later on.. but i will have to continue with it

simple fix:
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Apr 2010 23:30 Edited at: 29th Apr 2010 23:31
I don't know if that while statement is safe...
The DB boolean functions actually returns an integer, which value is either 1 or 0. The C++ conditional statements are supposed to work with the bool datatype.

You could try this instead;

Also, what data type is fi?

Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 30th Apr 2010 08:10
0 is false, anything else is true

haliop
User Banned
Posted: 1st May 2010 03:01
here is the code from my program
the one thats written above is just something i scribbeld sorry
this one is for the 3D Object GetFreeObject
it was the same for Image until ive changed it to counter.


this was the same for Image
but every time it got to 8 it stucked ..
so ive changed it to
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 1st May 2010 03:50 Edited at: 1st May 2010 03:51
Are you by any chance compiling with optimizations? Either optimize for size (/Os) or optimize for speed (/Ot)? I don't recall the details, but I do recall reading that compiling for optimizations tends to "short-circuit" the code path somehow where:

while(dbImageExist(x))

may short-circuit but can be fixed with

while (dbImageExist(x) == 1)

or - for better compiler level error trapping

while (1 == dbImageExist(x))

since 1 is a constant and you can't accidentally assign a value to a constant (the compiler will catch it) thus

while (1 = dbImageExist(x)) will fail to compile...

Just checking,

JTK
haliop
User Banned
Posted: 1st May 2010 05:40
good to know
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 1st May 2010 06:07
I bring this up because it may be what Rudolpho is trying to bring up in their post above...

In either case:

while (1 == dbImageExist(x)) and
while (dbImageExist(x) == 1)

Ultimately translates to a bool value...

NOTE: while (dbImageExist(x) = 1) will also fail to compile...

For this reason, I *always* check for a specific value in my conditionals; even if the value is unknown... ie:

if (NULL != obj) as opposed to
if (obj)


* There's not much more typing required (we programmers are at heart lazy),

* The code is easier to read (at least the intended conditional checks), and;

* It traps errors at the first possible phase of identification (short of intelli-sense) - which by the way, works wonders too if you heed it's *silent* warnings... That is, if intelli-sense suddenly stops working, chances are, you've got a bug (from my experience anyway) - Intelli-sense is pretty darn-smart...

JTK

Login to post a reply

Server time is: 2024-11-20 01:39:07
Your offset time is: 2024-11-20 01:39:07