mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 12:32:26 +00:00
Another try at #6522. This works here, for the most part, with no ill
effects that I can see. That said, I believe there is still a crash you could get. I'll explain in a moment. Since we may run into this kind of thing again, let me explain why this is necessary. The problem was that resetting the model was causing a signal to be emitted that the current index had changed, which was triggering an update of the Buffer, eventually. I'm not sure why this did not happen in Qt 4.5, but in Qt 4.6, you have to call beginResetModel() before doing anything, so that the combo box will remember its previous setting. Then you can change the data; then you can call endResetModel(). This will attempt to restore the previous setting. Only if it cannot do so will currentIndexChanged() be emitted. You can see, therefore, that if whatever the user did caused the current setting to become invalid---e.g., she deleted the only footnote---then the signal will be emitted and LyX will still crash. Still, that is a fair bit better than presently. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33702 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
039807ed28
commit
0bddd759d7
@ -41,8 +41,7 @@ namespace frontend {
|
||||
|
||||
TocTypeModel::TocTypeModel(QObject * parent)
|
||||
: QStandardItemModel(parent)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void TocTypeModel::reset()
|
||||
@ -50,6 +49,19 @@ void TocTypeModel::reset()
|
||||
QStandardItemModel::reset();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
void TocTypeModel::beginResetModel() {
|
||||
QStandardItemModel::beginResetModel();
|
||||
}
|
||||
|
||||
|
||||
void TocTypeModel::endResetModel()
|
||||
{
|
||||
QStandardItemModel::endResetModel();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -338,6 +350,9 @@ void TocModels::reset(BufferView const * bv)
|
||||
}
|
||||
|
||||
names_->blockSignals(true);
|
||||
#if QT_VERSION >= 0x040600
|
||||
names_->beginResetModel();
|
||||
#endif
|
||||
names_->insertColumns(0, 1);
|
||||
TocList const & tocs = bv_->buffer().masterBuffer()->tocBackend().tocs();
|
||||
TocList::const_iterator it = tocs.begin();
|
||||
@ -360,7 +375,11 @@ void TocModels::reset(BufferView const * bv)
|
||||
names_->setData(index, type, Qt::UserRole);
|
||||
}
|
||||
names_->blockSignals(false);
|
||||
#if QT_VERSION >= 0x040600
|
||||
names_->endResetModel();
|
||||
#else
|
||||
names_->reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,6 +38,10 @@ public:
|
||||
TocTypeModel(QObject * parent);
|
||||
///
|
||||
void reset();
|
||||
#if QT_VERSION >= 0x040600
|
||||
void beginResetModel();
|
||||
void endResetModel();
|
||||
#endif
|
||||
};
|
||||
|
||||
/// A class that adapt the TocBackend of a Buffer into standard Qt models for
|
||||
|
Loading…
Reference in New Issue
Block a user