Page 2 of 2

Re: Is there a bug in the scene saving commands?

Posted: Fri Aug 19, 2016 10:58 pm
by Mel
I think i am narrowing the search. When i save the scene, I create my own dialog to save a file, but to load files, i use Irr's default gui file chooser. Using my own dialog doesn't break (I save an empty scene,and it has dots instead of commas) but after i use the file open dialog (you don't have to pick any option, you just have to show that gui), the saved file shows commas.

Try this example (is your example modified to add a fileopen dialog and to save the scene after. I could reproduce the bug with it.

Code: Select all

 
// Testing serializing with animated models
 
#include <irrlicht.h>
 
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
 
using namespace irr;
 
int main(int argc, char *argv[])
{
    IrrlichtDevice * Device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640, 480));
    if (!Device)
        return false;
 
    scene::ISceneManager* smgr = Device->getSceneManager();
    video::IVideoDriver* videoDriver = Device->getVideoDriver();
 
    smgr->addCameraSceneNode(0, core::vector3df(30, 30, 100),
        core::vector3df(0, 0, 0),
        -1);
 
    smgr->addCubeSceneNode(10.0f, 0, -1);
    smgr->addLightSceneNode(0, core::vector3df(0, 50, 0),
        video::SColorf(1.0f, 1.0f, 1.0f),
        1000.0f);
 
    scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/dwarf.x"));
    //scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"));
    if (anms)
    {
        //anms->setScale(core::vector3df(5.f, 5.f, 5.f));   // ninja needs to be larger
        anms->setMaterialFlag(video::EMF_LIGHTING, false);
    }
 
    bool reloadScene = false;
    bool addOpenFile = true;
    bool done = false;
 
 
    while (Device->run())
    {
        if (Device->isWindowActive())
        {
            if (addOpenFile)
            {
                Device->getGUIEnvironment()->addFileOpenDialog(L"FOO");
                addOpenFile = false;
            }
 
            if (reloadScene)
            {
                smgr->saveScene("scenetest.xml");
                smgr->clear();
                smgr->loadScene("scenetest.xml");
                reloadScene = false;
                done = true;
            }
 
            if (Device->getTimer()->getTime() > 5000 && !done)
                reloadScene = true;
 
            videoDriver->beginScene(3,0xFF000000,1.0f,0);
            smgr->drawAll();
            Device->getGUIEnvironment()->drawAll();
            videoDriver->endScene();
        }
        Device->sleep(1);
    }
 
    Device->closeDevice();
    Device->drop();
 
    return 0;
}

Re: Is there a bug in the scene saving commands?

Posted: Sun Aug 21, 2016 8:48 pm
by CuteAlien
Thanks, I'll check it next week.

Re: Is there a bug in the scene saving commands?

Posted: Mon Aug 22, 2016 10:23 am
by CuteAlien
I made 2 changes now. First the FileOpenDialog had indeed a bug. It messed with LC_ALL instead of just LC_CTPYE and that could lead to wrong locals after trying to restore old settings (likely because there can be different settings so restoring just one value can't work).
And I also ensured now that saveScene always uses "c" type for LC_NUMERIC so it always writes dot's now.
Thanks for the updated test-case - I would have missed the bug in FileOpenDialog otherwise!

Re: [fixed]Is there a bug in the scene saving commands?

Posted: Mon Aug 22, 2016 11:28 pm
by Mel
Okay, tested and working fine!
Thanks to you guys!
This can be called fixed indeed! :)

Re: [fixed]Is there a bug in the scene saving commands?

Posted: Mon Aug 22, 2016 11:53 pm
by CuteAlien
Was rather interesting. I noticed that changing locale with setlocale in main didn't affect the library (Irrlicht linked as shared lib). Only changes in the library did affect it. Still not quite certain how it works - found online some thread which said it depends on how one links to MSVCRT.DLL (dynamic it would share, static it won't). So the library and the main application can have different locale settings at the same time.