Commit 8adb3287 authored by Jan Möbius's avatar Jan Möbius
Browse files

Added security checks for scripting to avoid segfaults

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@3892 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e99520b8
......@@ -74,11 +74,28 @@ void Core::createWidget(QString _objectName, QString _uiFilename) {
QUiLoader loader;
QFile uiFile(_uiFilename);
if ( !uiFile.exists() ) {
emit log(LOGERR,"File does not exist : " + _uiFilename );
return;
}
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
if ( ui == 0 ) {
emit log(LOGERR,"Unable to create QWidget from ui file for " + _objectName );
return;
}
QScriptValue scriptUi = scriptEngine_.newQObject(ui, QScriptEngine::ScriptOwnership);
if ( !scriptUi.isValid() ) {
emit log(LOGERR,"Unable to generate script interface for " + _objectName );
return;
}
scriptEngine_.globalObject().setProperty(_objectName, scriptUi);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment