mettli / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

using default constructor on for example textfield causes crash when later setting text #108

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. see summary
2.
3.

What is the expected behaviour? What happens instead?
the text should be set, it crashes

What version of the product are you using? On what operating system? Which
back-end (SDL/Allegro/OpenGL/other)?
current svn of guichan 2/1/09

Please provide any additional information below.
will probably effect other widgets using text class

Original issue reported on code.google.com by chriscam...@googlemail.com on 2 Jan 2009 at 7:26

GoogleCodeExporter commented 9 years ago
This happens when you create a TextField with the default ctor (the one without 
a 
string). In the ctor of the TextField it creates an internal Text object with 
the 
same type of ctor. A Text object which takes no string variable doesn't call 
mRows.push_back (...); (hence Text::mRows.size() == 0). When you call 
TextField::setText(const string& text) it calls Text::setRow(0, text) (which 
assumes 
Text::mRows.size() != 0) when in fact it should be calling 
mText::setContent(text) 
(my assumption being that if Text::mRows.size() == 0 then the Text object has 
no text 
in it).

If my assumptions are correct then attached patch will fix this bug.

Original comment by aaron.r....@gmail.com on 8 Dec 2009 at 9:12

Attachments:

GoogleCodeExporter commented 9 years ago
Our svn repo is abandon for our Git repository, do you have the bug with the 
latest
Git source as well?

Original comment by olof.nae...@gmail.com on 9 Dec 2009 at 9:06

GoogleCodeExporter commented 9 years ago
Yes the bug exists in the latest git.
If you take a look at the TextField empty ctor it calls the empty Text ctor. If 
you 
then look at TextField::setText you'll notice it calls Text::setRow which 
throws an 
exception if there are now rows in the Text object (which there clearly are 
not).

Original comment by aaron.r....@gmail.com on 9 Dec 2009 at 3:43

GoogleCodeExporter commented 9 years ago
Then we should apply your patch.

Original comment by olof.nae...@gmail.com on 9 Dec 2009 at 4:49