ofImage pointer instantiation

if you try to construct an ofImage pointer a la:

ofImage* myImage;

myImage->loadImage(“myImLoc.jpg”);

the ofImage class errors on :

bool isValid(){

return (bmp != NULL) ? true : false;

}

when done as a stack allocation (ofImage myImage, myImage.load…) it works fine.

just a heads up!

k

you mean in bool freeImageBitmap::isValid()?

i can’t remember exactly anymore but i think i had the same problem once.
i guess it had to do with the not so clean constructors (initialization).

i discussed that issue with zach and theo a while ago, sent them my changes and i guess/hope those will be included at some point. they didn’t make it into the current-svn-snapshot yet. but you should try to check that out.

hi keith

I’m not sure I understand the problem, can you send on an example? for example, are you allocating the object? I don’t see what the problem is, and I can’t recreate it with pointers over here…

didi, we are definitely working on the changes, especially to de-allocation on all objects, but we’ve had bigger things to work on recently, like linux support - and august has been kind of a slow time because of travel. However please know that we will not be implementing all of your changes, such as using non-default constructors, initialization lists, etc. We are going to try to find the best of all approaches, and we appreciate the feedback and patience. We will try to get on a faster release schedule in the next weeks.

  • z

hi zach.

nice to hear that, i’d appreciate it. but hey, no stress.
i know you have a tight schedule. so do i :wink:

and i can see that you don’t want to implement all of my suggestions.
that is ok for me since you guys have a somehow different perspective on code than i have.

but i think i have to be picky on that initialization lists issue.
i can’t see a single argument against initializing all variables properly?!?

anyway, maybe we should talk about it in real life, maybe at this years ars festival?!?

take care
/didi

hi didi,

yeah august is a rough month, especially in linz :slight_smile: good luck with everything - I heard that think will be in pixelspaces, good luck with it!

i can’t see a single argument against initializing all variables properly?!?

no, you misunderstand — we have and will try to initialize everything properly… seriously. the issue is *style*, we don’t think initialization lists is the way we want to allocate variables. We’d rather initialize them in the default constructor in a way most people would be used to from C, flash, java, etc. the idea is to keep the code as readable and normal as possible.

thanks for the feedback!

best,
zach

ps: I think the style issue of what we are debating is pretty well described here:

http://www.parashift.com/c+±faq-lite/c-…-l#faq-10.6

while the author argues in favor of initialization lists for performance reasons, which I can completely understand, I am still voting strongly for the argument for legibility / normalcy of the code…

thx zach, we are really glad to show think at pixelspaces. :slight_smile:

cheers
didi

[quote author=“didito”]
using initialization lists is cleaner, more efficient and professional, but surely not less legibile. in fact the coding style from a visual point of view (the format and layout) is just a matter of personal taste. i.e. i prefer their style because i learned it that way.[/quote]

I think we are debating something very small, which is a style issue.

personally, I am more used to, and I find much easier to read this:

  
  
ofSoundPlayer::ofSoundPlayer(){  
	bLoop 			= false;  
	bLoadedOk 		= false;  
	channel 		= -1;				  
	pan 			= 0.5f;					  
	volume 			= 1.0f;  
	internalFreq 	= 44100;  	  
	speed 			= 1;  
	bPaused 		= false;  
}  
  

then this:

  
  
ofSoundPlayer::ofSoundPlayer() :   
bLoop(false),  
bLoadedOk(false),  
channel(-1),  
pan(0.5f),  
internalFreq(44100),  
speed(1),  
bPaused(false)  
{  
  
}  
  

but if you look at most all of the constructors in OF, we are mostly dealing with common variables and really not alot is happening anyway. therefore, I really don’t think it matters which way we do it. I think then it’s more important to write code in a way which is more universally understood… so that your average literate java, flash, javascript, etc programmer can look and say “ok, those variables are being set.”

at any rate, I am super happy to debate these things, and our mind is definitely open, and I have to admit (a) I have never used initialization lists (b) I learned alot researching them in the process © I could be open to using them in more complicated situations, or where performance was really an issue.

thanks!!
zach

ps: as a side note, theo and I put in our first template code into the next version of OF - so we are not totally against modern c++ style coding :slight_smile:

you are absolutely right. this is really a small style issue.
and you might be right that the average literate … programmer understands your approach more easily.

i’m glad about your open-mindness.
looking forward to the next OF version with more modern c++ style coding :wink:

bye,
didi