I'm making a texture atlas builder that takes several images and builds them into one large image for use later as a texture atlas. The program is mostly done, with a few things left to do, but I keep running into this stupid problem:
When you click add image (after clicking File -> New to create a new atlas), a modal window comes up that contains a text box and button to browse for the new image file and a spinbox for scaling the image. I set the range of the scale factor spinbox from 1 to 0.1, and the step size to 0.1. The problem is, whenever I type into the spinbox or bring its value to 0.1 via the arrows, the program crashes with a stack overflow error. I have no idea why, and when I set the minimum value of the spinbox to anything else all the problems go away.
I'd really appreciate any insight into why this is happening. Thanks in advance.
Source can be downloaded here.
http://www.mediafire.com/?zj1mzzzgwtt
[fixed]spinbox killing the stack
Please be a little bit more specific. I'm not going to browse through the sources of your whole project searching for a place where there might be a problem (you didn't even give the filename or function where the problem sits).
Please try to reduce your problem to a few reproducible lines. Preferably post the lines in the forum here.
Please try to reduce your problem to a few reproducible lines. Preferably post the lines in the forum here.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Sorry. The function just creates a modal window with the browse button, text box, and spinbox. If you want to see how the event handler manages these controls, just look at EventReceiver.cpp
I'm not doing anything with the spinbox in the event receiver other than just calling GetValue() when the user clicks Ok on the dialog.
I don't know what could be causing this. I have another spinbox control in the main window that works perfectly, and whenever I set the range to anything else everything works fine.
I'm not doing anything with the spinbox in the event receiver other than just calling GetValue() when the user clicks Ok on the dialog.
Code: Select all
void BuilderGUI::ShowAddImageDialog(void)
{
u32 width = 320;
u32 height = 150;
addImgDlg = env->addWindow(rect<s32>(position2d<s32>(SCREEN_W / 2 - width / 2, SCREEN_H / 2 - height / 2), dimension2d<s32>(width, height)),
true, L"Add an Image");
imgFilenameBox = env->addEditBox(NULL, rect<s32>(position2d<s32>(10, 30), dimension2d<s32>(200, 22)), true, addImgDlg);
imgFilenameBox->setTextAlignment(EGUIA_LOWERRIGHT, EGUIA_CENTER);
env->addButton(rect<s32>(position2d<s32>(220, 30), dimension2d<s32>(95, 22)), addImgDlg, GUI_ID_ADD_DIALOG_BROWSE_FILE, L"Browse...", L"Browse for a file");
env->addStaticText(L"Image scaling factor:", rect<s32>(position2d<s32>(10, 70), dimension2d<s32>(200, 22)), false, true, addImgDlg);
imgScaleNUD = env->addSpinBox(NULL, rect<s32>(position2d<s32>(220, 70), dimension2d<s32>(95, 22)), true, addImgDlg);
imgScaleNUD->setDecimalPlaces(2);
imgScaleNUD->setStepSize(0.10f);
imgScaleNUD->setValue(1.0f);
imgScaleNUD->setRange(0.10f, 1.00f);
env->addButton(rect<s32>(position2d<s32>(width / 2 - 95 - 10, 110), dimension2d<s32>(95, 22)), addImgDlg, GUI_ID_ADD_DIALOG_OK, L"OK");
env->addButton(rect<s32>(position2d<s32>(width / 2 + 10, 110), dimension2d<s32>(95, 22)), addImgDlg, GUI_ID_ADD_DIALOG_CANCEL, L"Cancel");
}
OK, I can reproduce it. Nice bug - I'll look into it.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Thanks for reporting. It's fixed now in the 1.6 branch in svn and will probably make in the upcoming 1.6.1 release.
Until then - avoid setting the range to 0.1 - it was caused by a floating point rounding error which happens due to computer not being able to really represent 0.1
Or apply that patch which I added to Irrlicht:
Until then - avoid setting the range to 0.1 - it was caused by a floating point rounding error which happens due to computer not being able to really represent 0.1
Or apply that patch which I added to Irrlicht:
Code: Select all
Index: source/Irrlicht/CGUISpinBox.cpp
===================================================================
--- source/Irrlicht/CGUISpinBox.cpp (revision 2961)
+++ source/Irrlicht/CGUISpinBox.cpp (working copy)
@@ -236,9 +236,9 @@
void CGUISpinBox::verifyValueRange()
{
f32 val = getValue();
- if ( val < RangeMin )
+ if ( val+core::ROUNDING_ERROR_f32 < RangeMin )
val = RangeMin;
- else if ( val > RangeMax )
+ else if ( val-core::ROUNDING_ERROR_f32 > RangeMax )
val = RangeMax;
else
return;
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
I love you for posting !!!CuteAlien wrote:Or apply that patch which I added to Irrlicht:
![Very Happy :D](./images/smilies/icon_biggrin.gif)
while(!asleep) sheep++;
IrrExtensions:![Image](http://abusoft.g0dsoft.com/Irrlicht/gfx/logo.jpg)
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
![Image](http://abusoft.g0dsoft.com/Irrlicht/gfx/logo.jpg)
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java