Fix some bugs in script system when using multiple scripts
This commit is contained in:
+1
-7
@@ -111,12 +111,6 @@ void ScriptContainer::updateValuesTable(QTableWidget *widget)
|
|||||||
{
|
{
|
||||||
QString valu;
|
QString valu;
|
||||||
|
|
||||||
if (widget->columnCount() == 0)
|
|
||||||
{
|
|
||||||
widget->insertColumn(0);
|
|
||||||
widget->insertColumn(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (QString paramName, scriptParams)
|
foreach (QString paramName, scriptParams)
|
||||||
{
|
{
|
||||||
valu = scriptEngine.globalObject().property(paramName).toString();
|
valu = scriptEngine.globalObject().property(paramName).toString();
|
||||||
@@ -124,7 +118,7 @@ void ScriptContainer::updateValuesTable(QTableWidget *widget)
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < widget->rowCount(); i++)
|
for (int i = 0; i < widget->rowCount(); i++)
|
||||||
{
|
{
|
||||||
if (widget->item(i, 0)->text().compare(paramName) == 0)
|
if (widget->item(i, 0) && widget->item(i, 0)->text().compare(paramName) == 0)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
if (!widget->item(i, 1)->isSelected())
|
if (!widget->item(i, 1)->isSelected())
|
||||||
|
|||||||
+10
-1
@@ -43,6 +43,9 @@ ScriptingWindow::ScriptingWindow(const QVector<CANFrame> *frames, QWidget *paren
|
|||||||
|
|
||||||
elapsedTime.start();
|
elapsedTime.start();
|
||||||
valuesTimer.start(1000);
|
valuesTimer.start(1000);
|
||||||
|
|
||||||
|
ui->tableVariables->insertColumn(0);
|
||||||
|
ui->tableVariables->insertColumn(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptingWindow::~ScriptingWindow()
|
ScriptingWindow::~ScriptingWindow()
|
||||||
@@ -117,6 +120,13 @@ void ScriptingWindow::showEvent(QShowEvent* event)
|
|||||||
|
|
||||||
void ScriptingWindow::changeCurrentScript()
|
void ScriptingWindow::changeCurrentScript()
|
||||||
{
|
{
|
||||||
|
ui->tableVariables->clear();
|
||||||
|
for (int i = 0; i < ui->tableVariables->rowCount(); i++) ui->tableVariables->removeRow(0);
|
||||||
|
QStringList labels;
|
||||||
|
labels.append("Parameter");
|
||||||
|
labels.append("Value");
|
||||||
|
ui->tableVariables->setHorizontalHeaderLabels(labels);
|
||||||
|
|
||||||
int sel = ui->listLoadedScripts->currentRow();
|
int sel = ui->listLoadedScripts->currentRow();
|
||||||
if (sel < 0) return;
|
if (sel < 0) return;
|
||||||
|
|
||||||
@@ -130,7 +140,6 @@ void ScriptingWindow::changeCurrentScript()
|
|||||||
currentScript = container;
|
currentScript = container;
|
||||||
editor->setPlainText(container->scriptText);
|
editor->setPlainText(container->scriptText);
|
||||||
editor->setEnabled(true);
|
editor->setEnabled(true);
|
||||||
ui->tableVariables->clear();
|
|
||||||
connect(this, SIGNAL(updateValueTable(QTableWidget*)), currentScript, SLOT(updateValuesTable(QTableWidget*)));
|
connect(this, SIGNAL(updateValueTable(QTableWidget*)), currentScript, SLOT(updateValuesTable(QTableWidget*)));
|
||||||
connect(this, SIGNAL(updatedParameter(QString,QString)), currentScript, SLOT(updateParameter(QString,QString)));
|
connect(this, SIGNAL(updatedParameter(QString,QString)), currentScript, SLOT(updateParameter(QString,QString)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Scripting Interface</string>
|
<string>Scripting Interface</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,4">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,4">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Reference in New Issue
Block a user