From: Richard Heck Date: Wed, 10 Mar 2010 18:41:28 +0000 (+0000) Subject: Another try at #6522. This works here, for the most part, with no ill X-Git-Tag: 2.0.0~3838 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=0bddd759d72f0ba360ccd71c0899c7770b891565;p=features.git 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 --- diff --git a/src/frontends/qt4/TocModel.cpp b/src/frontends/qt4/TocModel.cpp index b8da14aa22..e6d6d08b24 100644 --- a/src/frontends/qt4/TocModel.cpp +++ b/src/frontends/qt4/TocModel.cpp @@ -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 } diff --git a/src/frontends/qt4/TocModel.h b/src/frontends/qt4/TocModel.h index 7475416160..b177880878 100644 --- a/src/frontends/qt4/TocModel.h +++ b/src/frontends/qt4/TocModel.h @@ -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