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;
}
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
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