[fixed] EditBox selecting text

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
TekniX
Posts: 24
Joined: Tue May 01, 2007 12:39 pm

[fixed] EditBox selecting text

Post by TekniX »

Hi,

Short : Selecting text in order to scroll through an editbox crashes the programm

Long :
OS : Linux
Irrlicht version : 1.7.1

main.cpp

Code: Select all


#include <irrlicht.h>
#include "driverChoice.h"
#include <iostream>
#include <string>


using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

//This function creates the UI Element for adding nodes.
int createWindow(IGUIEnvironment *env)
{
	int WINDOWSIZEX = 400; 
	int WINDOWSIZEY = 400;		
	IGUIWindow *addNodeWindow = env->addWindow(rect<s32>(((WINDOWSIZEX-WINDOWSIZEX/2)-100),((WINDOWSIZEY-WINDOWSIZEY/2)-200),
			((WINDOWSIZEX-WINDOWSIZEX/2)+195),((WINDOWSIZEY-WINDOWSIZEY/2)+133)),
			  true, // modal?
     	L"Add Node",0,811);
				
	//Create the text for Name plus the edit box for the name 
	env->addStaticText(L"Name",rect<s32>(15,33,65,58),false,false,addNodeWindow,999,false);
	IGUIEditBox *nodeName = env->addEditBox(L"",rect<s32>(80,30,250,55),true,addNodeWindow,802);
	nodeName->setMax(25);
	env->setFocus(nodeName);
		//Create the text for text and the edit box for it, then set up the editbox
	env->addStaticText(L"Text",rect<s32>(15,80,65,105),false,false,addNodeWindow,998,false);
	IGUIEditBox *textData = env->addEditBox(L"",rect<s32>(80,80,250,235),true,addNodeWindow,803);
	textData->setMax(5000);
	textData->setAutoScroll(true);
	textData->setMultiLine(true);
	textData->setWordWrap(true);
	textData->setTextAlignment(EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);
	
		//add ok and cancel button
	IGUIButton *add= env->addButton(rect<s32>(80,255,120,280),addNodeWindow,102,0,L"Adds node");
	IGUIButton *quit = env->addButton(rect<s32>(130,255,195,280),addNodeWindow,101,0, L"Exits Window");
	return 1;
}


#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif

int main(int argc, char *argv[])
{
	//IF we want to store graphics driver stuff inside the configuration file, we should do the reading of it here 
	//readConfiguration();
	
	IrrlichtDevice * device = createDevice(EDT_SOFTWARE, dimension2d<u32>(800,800));

	if (device == 0)
		return 1; // could not create selected driver.

	/* The creation was successful, now we set the event receiver and
		store pointers to the driver and to the gui environment. */

	device->setWindowCaption(L"test");
	device->setResizable(false);

	IVideoDriver* driver = device->getVideoDriver();
	
	int ui = 0;
	
	IGUIEnvironment* env = device->getGUIEnvironment();
	
	//MyEventReceiver receiver;	
	
	
//	device->setEventReceiver(&receiver);


	while(device->run() && driver)
		if (device->isWindowActive())
		{
			
			driver->beginScene(true, true, SColor(0,0,0,0));
			if ( ui == 0 ) 
			{
				ui = createWindow(env);
			}
			env->drawAll();
			
			driver->endScene();
		}
	
	device->drop();

	return 0;
}
Makefile

Code: Select all

# Makefile for Irrlicht Examples
# It's usually sufficient to change just the target name and source file list
# and be sure that CXX is set to a valid compiler
Target = ./
Sources = main.cpp
# general compiler settings
CPPFLAGS = -I /home/test/include -I ./ -I/usr/X11R6/include -I ./ -g
CXXFLAGS = -O3 -ffast-math
#CXXFLAGS = -g -Wall

#default target is Linux
all: all_linux

ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64
endif

# target specific settings
all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L/home/test/lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11
all_linux clean_linux: SYSTEM=Linux

# name of the binary - only valid for targets which set SYSTEM
DESTPATH = /home/test/main

all_linux all_win32:
	$(warning Building...)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS)

clean: clean_linux clean_win32
	$(warning Cleaning...)

clean_linux clean_win32:
	@$(RM) $(DESTPATH)

.PHONY: all all_win32 clean clean_linux clean_win32

reproducing the bug

create a directory called test in /home
create a file called main.cpp and a Makefile and put the above code into them, make, execute ./main. A window appears with an editbox, type in asd [enter] randomsh** [enter] random****** [enter] until you cannot see the top of the text anymore, then select text in order to scroll up. If it does not already crash here, select ( from top ) from left to right the text and then down, as if you wanted to scroll down.. now it should crash reporting the following

main: ../../include/irrString.h:330: T& irr::core::string<T, TAlloc>::operator[](irr::u32) [with T = wchar_t, TAlloc = irr::core::irrAllocator<wchar_t>]: Assertion `!(index>=used)' failed.
Aborted

Hope it really is a bug and not just something I did wrong (:roll:)
If you guys need anymore info ill be glad to help. Is there any chance of this getting fixed ? Maybe even a hotfix just for now ? What is a possible workaround ? Adding a scrollbar ?

Greetings Teknix
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I suspect it's the same bug reported here: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=42260

It's been fixed by now in svn release branch 1.7, so if it is that bug you have either to switch to latest svn, wait for next version or apply patch for revision 3508.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
TekniX
Posts: 24
Joined: Tue May 01, 2007 12:39 pm

Post by TekniX »

Ah ok, sorry for not finding it while doing the search.
Ok, ill try one of the proposed solutions.
Thank you very much :)

Greetings
TekniX
Posts: 24
Joined: Tue May 01, 2007 12:39 pm

Still not working :( ?

Post by TekniX »

Hi,

i just downloaded irrlicht 1.7.2 from the svn and it stillt crashes... Same error. Same test case as earlier.. Is it something related to my code then ? I have even downloaded this file

http://irrlicht.svn.sourceforge.net/vie ... xt%2Fplain

and replaced the irrString.h in my include but still no luck..

Any ideas ?

Thank you again
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I just tried reproducing it once more and it doesn't crash here.
I was using svn branches/releases/1.7

My best guess is still that this is the bugfix I mentioned above as that was exactly crashing in this situation. Note that this wasn't a bug in irrString, but in CGUIEditBox.cpp, so replacing the header won't fix it.

Could it be that you maybe still link with the old library?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
TekniX
Posts: 24
Joined: Tue May 01, 2007 12:39 pm

hmmm I give up :-/

Post by TekniX »

Hey CuteAlien thank you very much for replying again.
Hmm sorry, I m to little into this svn stuff and all of that.. I tried replacing CGUIEditbox.cpp with the one you mentioned from the releases , the one thats upmost, where you write that its fixed ( the bug in the mouse selection ) , then I recompiled but still crashing..
I also tried with the CGUIEditbox.cpp from trunk same thing.

Do I need to get the entire /releases/1.7 source code bulk or should that one file be enough ?

I guess i will just have to wait for the next release ;)

Greetz

ps : sorry wenn ich mich damit doof anstell aber hab svn und so noch nie benutzt und check überhaupt nich was da jetzt das neueste ist, weil bei der wo du des mit dem bug fix dazugeschrieben hast steht revision 3508 und bei der im Trunk verzeichnis ( anstelle von releases ) steht 3556 -> sollte doch also eigentlich neuer sein .. naja, trotzdem vielen Dank erstmal :)
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Svn is like this:
branches are stable versions which only get bugfixes
trunk is development version for next release (Irrlicht 1.8)
And every few weeks all bgufixes from the stable versions are merged into trunk.

But this bugfix is alreay in both versions. It's just a single line as you can see in this patch: http://irrlicht.svn.sourceforge.net/vie ... 17&r2=3508

So in your case I'm still guessing the same as above - that you might link against another irrlicht version. In your makefile you have -L/home/test/lib/Linux - so could it be that you still have an old libIrrlicht.a (or .so) in there? Because new versions are alway put into lib/Linux and maybe you forgot to copy that over after you re-compiled the engine.

edit: or maybe it finds another irrlicht first which you have installed in usr/lib or usr/local/lib
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
TekniX
Posts: 24
Joined: Tue May 01, 2007 12:39 pm

Post by TekniX »

Hey CuteAlien,

ok, now at least I have a basic idea of what svn is. Ill read the wikipedia on it ( promise ;) ) .
Actually I never reallly recompiled the engine... out of some strange reason I thought that copying the new CGUIEditBox.cpp would be enough .. -> *dooh* .Sorry for that. Im trying recompiling right now.
I never had any version before 1.7.1 on this machine so.. Well.
I think this is done for now... If I dont get it to work with recompile+replace of CGUIEditBox ill just wait for 1.8 and if it still happens ill file a new bug report, because then obviously it should be working :) .

Thank you very much :)

Kind regards,

TekniX
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Ok :-) If you have trouble you can also often get quick help on IRC.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

I don't know if that could help, but we used a modified CGUIEditBox from Irrlicht 1.7 that was crashing in MOUSE selection and was scrolling. The selection was going out of the allocated buffer for the text.

Tested the CGUIEditBox GUI in Irrlicht 1.7.2 and it seem stable. Look the problem is fixed in 1.7.2
Post Reply