[RESOLVED] Device functions causing a crash

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Some Moron
Posts: 12
Joined: Sat Jun 04, 2011 7:04 pm

[RESOLVED] Device functions causing a crash

Post by Some Moron »

I've done some searches for this, but I haven't found anyone with the exact problem I'm having. When trying to call createAndOpenFile, the program crashes every time. The debug outputs I've added (printing 2 and 3 to standard output) confirm that this is the line causing the problem, as I get a 2 and not a 3.

Code: Select all

        irr::io::IFileSystem* fs = device->getFileSystem();
        irr::core::stringw fileName = mapFolder + name;
        std::cout << "2";
        irr::io::IReadFile* wf = fs->createAndOpenFile(fileName);
        std::cout << "3";
The only thing I can think of is that a stringw is not a valid input for createAndOpenFile, but it does not give me any compiler errors or warnings to confirm this.

On a related note, can anyone confirm if "createAndOpenFile" actually does create a file if it doesn't exist? If so, how do I open a file without trying to create it?
Last edited by Some Moron on Mon Dec 10, 2012 7:20 pm, edited 1 time in total.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: createAndOpenFile causing a crash

Post by christianclavet »

Can you do a check on the FS pointer?
like this:

Code: Select all

irr::io::IFileSystem* fs = device->getFileSystem();
irr::core::stringw fileName = mapFolder + name;
 
if (fs)
    irr::io::IReadFile* wf = fs->createAndOpenFile(fileName);
  else
    std::cout << "Invalid pointer";
If you can, check in your compiler debugger to pinpoint the problem. Perhaps it's your device pointer or the filesystem pointer.
Some Moron
Posts: 12
Joined: Sat Jun 04, 2011 7:04 pm

Re: createAndOpenFile causing a crash

Post by Some Moron »

Well, now I'm feeling mildly stupid. Thanks for the help anyway, but it turned out that I was using the wrong compiled DLL - the VS one, when the project was being built with Code::Blocks. Compiling Irr and using the new DLL makes everything work smoothly.
Post Reply