PDA

View Full Version : Runtime error: Invalid parameter passed to C runtime function.



Delirium
25th September 2010, 02:09
Hello.

I am writing an editor for lua scripts of a specific game using QScintilla. I have written a stand-alone class (the class name is LuaEditor) for the editor widget. Inside mainwindow.h I have written this function to help me get the instance of the MainWindow so I can change some of its properties through the LuaEditor class:

static MainWindow *getInstance()
{
static MainWindow window;
return &window;
}

On LuaEditor class there's a function, newFile(), which initializes the editor widget...the code of the newFile() function is this:

void LuaEditor::newFile()
{
isUntitled = true;
currentFile = "newScript.lua";
MainWindow::getInstance()->setWindowTitle(tr("QtLuaPad - %1").arg(currentFile));
setText(tr("-- Created using QtLuaPad on %1\n\nfunction onUse(cid, item, frompos, item2, topos)\n\treturn TRUE\nend").arg(QDate::currentDate().toString()));
connect(this, SIGNAL(textChanged()), this, SLOT(setDocumentModified()));
}

When I am trying to run the application (release mode), the application crashes and I get the following error:

Invalid parameter passed to C runtime function.
C:\Qt\Projects\QtLuaPad-build-desktop\release\QtLuaPad.exe exited with code 3

and also this error msgbox:

The application has requestes the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

Anybody knows what's going on here? I can provide you with the full source code in case you need it to solve my case. Thanks in advance.

Yours,
Delirium.

wysota
25th September 2010, 09:20
I can provide you with the full source code in case you need it to solve my case.
It would be more useful if you tried reproducing the same behaviour with a minimal compilable example.