Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions QMLComponents/controls/jasplistcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool JASPListControl::containsInteractions() const

void JASPListControl::termsChangedHandler()
{
if (checkLevelsConstraints())
if (model() && checkLevelsConstraints())
{
setColumnsTypes(model()->getUsedTypes());
setColumnsNames(model()->terms().values());
Expand Down Expand Up @@ -245,7 +245,7 @@ JASPControl *JASPListControl::getRowControl(const QString &key, const QString &n

columnType JASPListControl::getVariableType(const QString &name)
{
return model()->getVariableType(name);
return model() ? model()->getVariableType(name) : columnType::unknown;
}

int JASPListControl::count()
Expand Down Expand Up @@ -273,7 +273,8 @@ std::vector<std::string> JASPListControl::usedVariables() const

JASPControls JASPListControl::getMDSubItems(const QQuickItem*) const
{
const Terms& terms = model()->terms();
if (!model())
return {};

// If row components are used, use only the items of the first row (if exists) to generate the help.
const ListModel::RowControlMap & map = model()->getAllRowControls();
Expand Down Expand Up @@ -329,7 +330,7 @@ bool JASPListControl::hasMandatoryType() const

bool JASPListControl::_checkLevelsConstraintsForVariable(const QString& variable)
{
if (variable.isEmpty())
if (variable.isEmpty() || !model())
return true;

columnType type = (columnType)model()->requestInfo(VariableInfo::VariableType, variable).toInt();
Expand Down Expand Up @@ -377,6 +378,9 @@ bool JASPListControl::_checkLevelsConstraints()
{
bool checked = true;

if (!model())
return checked;

for (const Term& term : model()->terms())
{
if (!_checkLevelsConstraintsForVariable(term.value()))
Expand Down Expand Up @@ -429,7 +433,7 @@ void JASPListControl::_setAllowedVariables()

emit allowedColumnsIconsChanged();

if (form() && form()->initialized())
if (model() && form() && form()->initialized())
// If the allowed columns have changed, then refresh the model so that columns that are not allowed anymore are removed.
model()->refresh();
}
Expand Down
Loading