add isValid methods to results and list
This commit is contained in:
parent
df716d3da1
commit
592a35a69e
|
@ -90,15 +90,23 @@ Results::~Results()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Results::is_valid() const
|
||||||
|
{
|
||||||
|
if (m_table && !m_table->is_attached())
|
||||||
|
return false;
|
||||||
|
if (m_mode == Mode::TableView && (!m_table_view.is_attached() || m_table_view.depends_on_deleted_object()))
|
||||||
|
return false;
|
||||||
|
if (m_mode == Mode::LinkView && !m_link_view->is_attached())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Results::validate_read() const
|
void Results::validate_read() const
|
||||||
{
|
{
|
||||||
if (m_realm)
|
if (m_realm)
|
||||||
m_realm->verify_thread();
|
m_realm->verify_thread();
|
||||||
if (m_table && !m_table->is_attached())
|
if (!is_valid())
|
||||||
throw InvalidatedException();
|
|
||||||
if (m_mode == Mode::TableView && (!m_table_view.is_attached() || m_table_view.depends_on_deleted_object()))
|
|
||||||
throw InvalidatedException();
|
|
||||||
if (m_mode == Mode::LinkView && !m_link_view->is_attached())
|
|
||||||
throw InvalidatedException();
|
throw InvalidatedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,9 @@ public:
|
||||||
static void set_table_view(Results& results, TableView&& tv);
|
static void set_table_view(Results& results, TableView&& tv);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Returns if this Results class is still valid
|
||||||
|
bool is_valid() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SharedRealm m_realm;
|
SharedRealm m_realm;
|
||||||
const ObjectSchema *m_object_schema;
|
const ObjectSchema *m_object_schema;
|
||||||
|
|
Loading…
Reference in New Issue