console crashes if words are too long


19-11-2007 14:55:16

hi there,
I just downloaded v0.97 (and later the latest svn-version) of QuickGUI to give it a try. I really got quick into it and its very easy to use, good job ;-)

However, I stepped into a first crash with the console/labelarea:
if you input a line without whitespaces, that is wider than the textarea itself and submit it, the console crashes, and i think i figured out why:

// The rest of the caption is less than the width of the Widget.
if( end == static_cast<int>(mCaption.length()) )
return end;
// Remaining portion of caption is larger than the width of the widget.
// Iterate backwards until we find a space.
while( !mText->isSpace(mCaption[end]) )

return end;

This part of the _getLine(int startIndex)-Method in quickguilabelarea.cpp does not take into account, that a word without whitespaces could have been to long for the text area. The 'else' part tries to roll back but won't find any Whitespace and so try to test mCaption[-1].

~~~ Philipp


19-11-2007 17:33:56

Thanks for spotting this, I forgot to gaurd against that case. What should be the default behavior for this? Just breaking the line at the point where it is longer than the space allotted, and continuing the text below, right?


19-11-2007 22:59:18

I'd like to point out some other points:

First, could you provide a focus funciton which gains focus of mInputBox?
In our application, if you press ^ , the console pops up and the focus should be in the input box (so you don't need a mouse cursor and click in it)

Also, there seems to be strange behavior when I manually call addText:
error LNK2019: unresolved external symbol "public: void __thiscall QuickGUI::Console::addText(class Ogre::UTFString const &)" (?addText@Console@QuickGUI@@QAEXABVUTFString@Ogre@@@Z) referenced in function "public: void __thiscall psi::EgoDevice::CreateGUI(void)" (?CreateGUI@EgoDevice@psi@@QAEXXZ)

This type of error mostly occurs, when a method is declared but not defined.
But I check the quickGUI code and it actually is there.

Do you have an idea what could cause this?
I tried it with the quickGUIDemo - same error.

The reason why we would need this functionality is, if the user enters a console instruction, we'd like to give him/her feedback ("unknown", "new value = ... " etc. )

Thanks for you time ;)


19-11-2007 23:14:58

Awesome idea.

I will make sure a "focus" function exists, and that the input text box is given focus.

For the error, I'm not sure the problem.. could be that I'm forgetting to export Console or LabelArea to dll, but I've ran these in the demo before. Maybe your lib or headers is/are not in sync with the code base? I'll see if I can repro this at home.

Also, it may be a couple of days before I commit it. I'll add it tonight, but I can't easily commit at the moment, without introducing an awkward state of QGUI.


20-11-2007 07:32:57

What should be the default behavior for this? Just breaking the line at the point where it is longer than the space allotted, and continuing the text below, right?
Yes, i think in such a case, a word is just cutted and continued in the next line.

~~~ Philipp


22-11-2007 11:54:09

I just came up with another console-nice2have ;)

How about "iterating" through the last entered commands with the UP- & DOWN -cursor. (dos-like)
Is this technically possible without having to rebuild the whole console?


22-11-2007 20:35:21

Regarding the addText issue you had earlier, the Console class was not being exported to the dll, so this is fixed now. (need to commit..)

For your request I'd need to make a container (probably vector) to store entered input. Pretty simple to do, I will add this in, and tie it to the up/down arrows. (is this what you mean by up/down cursor?)


23-11-2007 08:08:11

(is this what you mean by up/down cursor?)

yeah i guess so :D
cursor probably was the wrong name, since the mouse has a cursor and the keyboard has keys ... ;)

thanks anyway!