Skip to content

Commit

Permalink
Python Charts - Replace $$ by chartid in scripts
Browse files Browse the repository at this point in the history
It worked for the console, but it failed for scripts running on a separate thread.
Fixes #4185
  • Loading branch information
amtriathlon committed Mar 1, 2022
1 parent eb66524 commit 61afa38
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Charts/PythonChart.cpp
Expand Up @@ -580,7 +580,12 @@ PythonChart::setState(QString)
void
PythonChart::execScript(PythonChart *chart)
{
python->runline(ScriptContext(chart->context), chart->script->toPlainText());
QString line = chart->script->toPlainText();

// replace $$ with chart identifier (to avoid shared data)
line = line.replace("$$", chart->console->chartid);

python->runline(ScriptContext(chart->context), line);
}

void
Expand Down Expand Up @@ -611,13 +616,8 @@ PythonChart::runScript()
// set to defaults with gc applied
python->cancelled = false;

QString line = script->toPlainText();

try {

// replace $$ with chart identifier (to avoid shared data)
line = line.replace("$$", console->chartid);

// run it
QFutureWatcher<void>watcher;
QFuture<void>f= QtConcurrent::run(execScript,this);
Expand Down

0 comments on commit 61afa38

Please sign in to comment.