Commit 2096872f authored by Jan Möbius's avatar Jan Möbius

Correctly handle script path

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16883 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1bcbbbff
......@@ -71,6 +71,7 @@ ScriptingPlugin::ScriptingPlugin() :
highlighterLive_(0),
highlighterList_(0),
lastFile_(""),
scriptPath_(""),
debuggerButton_(0)
#ifdef ENABLE_SCRIPT_DEBUGGER
#ifdef QT_SCRIPTTOOLS_LIB
......@@ -351,9 +352,8 @@ void ScriptingPlugin::slotExecuteScript( QString _script ) {
/// Switch scripting mode on
OpenFlipper::Options::scripting(true);
// Get the filename of the script and set it in the scripting environment
engine->globalObject().setProperty("ScriptPath",QScriptValue(engine,lastFile_.section(OpenFlipper::Options::dirSeparator(), 0, -2)));
engine->globalObject().setProperty("ScriptPath",OpenFlipper::Options::currentScriptDirStr());
// Execute the script
engine->evaluate( _script );
......@@ -404,6 +404,9 @@ void ScriptingPlugin::slotExecuteFileScript( QString _filename ) {
if ( OpenFlipper::Options::gui() )
scriptWidget_->currentScript->setPlainText(script);
// Set the correct execution environment
OpenFlipper::Options::currentScriptDir( _filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) );
slotExecuteScript(script);
} else
......@@ -612,8 +615,8 @@ void ScriptingPlugin::slotSaveScriptAs(){
}
lastFile_ = filename;
OpenFlipper::Options::currentScriptDir( QFileInfo(filename).absolutePath() );
scriptWidget_->actionSave_Script->setEnabled( false );
}
......@@ -689,10 +692,11 @@ void ScriptingPlugin::showScriptInEditor(QString _code)
return;
/*
* this is called from the VSI plugin
* This is called from the VSI and other plugins with pure code
* we do not want to overwrite any previously opened scripts
*/
lastFile_ = "";
OpenFlipper::Options::currentScriptDir( "" );
showScriptWidget ();
......
......@@ -230,6 +230,11 @@ private :
QString lastFile_;
/** Path to the directory where the current script is executed.
* This might be empty, if a script is not saved!
*/
QString scriptPath_;
QAction* debuggerButton_;
#ifdef ENABLE_SCRIPT_DEBUGGER
......
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