Skip to content

Commit

Permalink
Fix syntax check on columns flux (#5350)
Browse files Browse the repository at this point in the history
* Make sure to update ColumnEncoder at right times

* make sure textarea runs checkSyntax whenever amount of columns changes

* RowComponent should get the right parent to be destroyed at the right time

JASP crashes when closing the workspace if a TextArea was open in an Analysis form.

---------

Co-authored-by: boutinb <[email protected]>
  • Loading branch information
JorisGoosen and boutinb authored Dec 14, 2023
1 parent 8f52963 commit d7f7375
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Desktop/data/datasetpackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,8 @@ QString DataSetPackage::insertColumnSpecial(int column, const QMap<QString, QVar

emit datasetChanged(tq(changed), tq(missingColumns), tq(changeNameColumns), false, true);

ColumnEncoder::setCurrentColumnNames(getColumnNames());

return QString::fromStdString(name);
}

Expand Down Expand Up @@ -2220,6 +2222,8 @@ bool DataSetPackage::insertColumns(int column, int count, const QModelIndex & ap

emit datasetChanged(tq(changed), tq(missingColumns), tq(changeNameColumns), true, false);

ColumnEncoder::setCurrentColumnNames(getColumnNames());

return true;
}

Expand Down Expand Up @@ -2253,6 +2257,8 @@ bool DataSetPackage::removeColumns(int column, int count, const QModelIndex & ap
#endif
emit datasetChanged(tq(changed), tq(missingColumns), tq(changeNameColumns), false, true);

ColumnEncoder::setCurrentColumnNames(getColumnNames());

return true;
}

Expand Down
3 changes: 0 additions & 3 deletions QMLComponents/components/JASP/Controls/TextArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ TextAreaBase
property bool useTabAsSpaces : true
property var nextTabItem

signal applyRequest()
signal editingFinished()

Component.onCompleted: control.editingFinished.connect(editingFinished)

function userEnteredInput() {
Expand Down
3 changes: 3 additions & 0 deletions QMLComponents/controls/jasplistcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ void JASPListControl::cleanUp()
control->cleanUp();
}

for (auto source : _sourceItems)
source->disconnectModels();

JASPControl::cleanUp();
}
catch (...) {}
Expand Down
1 change: 1 addition & 0 deletions QMLComponents/controls/rowcontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void RowControls::init(int row, const Term& key, bool isNew)
context->setContextProperty("rowValue", key.asQString());

_rowObject = qobject_cast<QQuickItem*>(_rowComponent->create(context));
_rowObject->setParent(_parentModel);
_context = context;

if (_rowObject) _setupControls();
Expand Down
7 changes: 6 additions & 1 deletion QMLComponents/controls/textareabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ void TextAreaBase::setUp()
_separators.push_back(separator.toString());
}

connect(this, SIGNAL(applyRequest()), this, SLOT(checkSyntaxHandler()));
//If "rowCount" changes on VariableInfo it means a column has been added or removed, this means the model should be reencoded and checked
//Fixes https://github.com/jasp-stats/jasp-issues/issues/2462
connect(VariableInfo::info(), &VariableInfo::rowCountChanged, this, &TextAreaBase::checkSyntaxHandler);

//Also do it on request of course ;)
connect(this, &TextAreaBase::applyRequest, this, &TextAreaBase::checkSyntaxHandler);
}

void TextAreaBase::rScriptDoneHandler(const QString & result)
Expand Down
2 changes: 2 additions & 0 deletions QMLComponents/controls/textareabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public slots:
signals:
void textTypeChanged();
void hasScriptErrorChanged();
void applyRequest();
void editingFinished();

protected slots:
void termsChangedHandler() override;
Expand Down

0 comments on commit d7f7375

Please sign in to comment.