Commit f4536529 authored by Jan Möbius's avatar Jan Möbius

Dont create ui elements from scripting in batch mode

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11416 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 53924104
......@@ -85,35 +85,39 @@ void Core::scriptLogFunction( QString _output) {
}
void Core::createWidget(QString _objectName, QString _uiFilename) {
QUiLoader loader;
if ( OpenFlipper::Options::gui()) {
QUiLoader loader;
QFile uiFile(_uiFilename);
QFile uiFile(_uiFilename);
if ( !uiFile.exists() ) {
emit log(LOGERR,tr("File does not exist : ") + _uiFilename );
return;
}
if ( !uiFile.exists() ) {
emit log(LOGERR,tr("File does not exist : ") + _uiFilename );
return;
}
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
if ( ui == 0 ) {
emit log(LOGERR,tr("Unable to create QWidget from ui file for ") + _objectName );
return;
}
if ( ui == 0 ) {
emit log(LOGERR,tr("Unable to create QWidget from ui file for ") + _objectName );
return;
}
QScriptValue scriptUi = scriptEngine_.newQObject(ui, QScriptEngine::ScriptOwnership);
QScriptValue scriptUi = scriptEngine_.newQObject(ui, QScriptEngine::ScriptOwnership);
if ( !scriptUi.isValid() ) {
emit log(LOGERR,tr("Unable to generate script interface for ") + _objectName );
return;
}
if ( !scriptUi.isValid() ) {
emit log(LOGERR,tr("Unable to generate script interface for ") + _objectName );
return;
}
scriptEngine_.globalObject().setProperty(_objectName, scriptUi);
scriptEngine_.globalObject().setProperty(_objectName, scriptUi);
ui->show();
ui->show();
} else {
emit log(LOGERR,tr("Error! Script tried to create Widget in ui less batc mode! Creation Aborted!"));
}
}
......
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