Doc: state that models are not thread-safe
Fixes: QTBUG-107598 Pick-to: 6.5 6.2 5.15 Change-Id: I0e7ea8d4b2094d92b3cad5eec5b30e6e3ac64018 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ccda3362464bfaff999b739aa81925c7b51075a9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
922f60c140
commit
71122209f4
14
src/corelib/doc/src/includes/models.qdocinc
Normal file
14
src/corelib/doc/src/includes/models.qdocinc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//! [thread-safety-section1]
|
||||||
|
\section1 Thread safety
|
||||||
|
|
||||||
|
Being a \l {Accessing QObject Subclasses from Other Threads}{subclass of
|
||||||
|
QObject}, \1 is not \l {Reentrancy and Thread-Safety}{thread-safe}. Any \1
|
||||||
|
model-related API should only be called from the thread the model object lives
|
||||||
|
in. If the \1 is connected with a view, that means the GUI thread, as that is
|
||||||
|
where the view lives, and it will call into the model from the GUI thread.
|
||||||
|
Using a background thread to populate or modify the contents of a model is
|
||||||
|
possible, but requires care, as the background thread cannot call any
|
||||||
|
model-related API directly. Instead, you should queue the updates and apply
|
||||||
|
them in the main thread. This can be done with \l {Signals and Slots Across
|
||||||
|
Threads}{queued connections}.
|
||||||
|
//! [thread-safety-section1]
|
@ -1499,6 +1499,8 @@ void QAbstractItemModel::resetInternalData()
|
|||||||
rows to the model, \l{QAbstractItemModel::}{beginInsertRows()} and
|
rows to the model, \l{QAbstractItemModel::}{beginInsertRows()} and
|
||||||
\l{QAbstractItemModel::}{endInsertRows()} must be called.
|
\l{QAbstractItemModel::}{endInsertRows()} must be called.
|
||||||
|
|
||||||
|
\include models.qdocinc {thread-safety-section1}{QAbstractItemModel}
|
||||||
|
|
||||||
\sa {Model Classes}, {Model Subclassing Reference}, QModelIndex,
|
\sa {Model Classes}, {Model Subclassing Reference}, QModelIndex,
|
||||||
QAbstractItemView, {Using drag and drop with item views},
|
QAbstractItemView, {Using drag and drop with item views},
|
||||||
{Simple Tree Model Example}, {Editable Tree Model Example},
|
{Simple Tree Model Example}, {Editable Tree Model Example},
|
||||||
@ -3730,7 +3732,7 @@ void QAbstractItemModel::multiData(const QModelIndex &index, QModelRoleDataSpan
|
|||||||
\note Some general guidelines for subclassing models are available in the
|
\note Some general guidelines for subclassing models are available in the
|
||||||
\l{Model Subclassing Reference}.
|
\l{Model Subclassing Reference}.
|
||||||
|
|
||||||
\note
|
\include models.qdocinc {thread-safety-section1}{QAbstractTableModel}
|
||||||
|
|
||||||
\sa {Model Classes}, QAbstractItemModel, QAbstractListModel
|
\sa {Model Classes}, QAbstractItemModel, QAbstractListModel
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user