]> git.lyx.org Git - features.git/commitdiff
Another try at #6522. This works here, for the most part, with no ill
authorRichard Heck <rgheck@comcast.net>
Wed, 10 Mar 2010 18:41:28 +0000 (18:41 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 10 Mar 2010 18:41:28 +0000 (18:41 +0000)
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

src/frontends/qt4/TocModel.cpp
src/frontends/qt4/TocModel.h

index b8da14aa22d710348119565583c719257c8eb8dd..e6d6d08b24605989c0c3d29d83d1259dde1aa339 100644 (file)
@@ -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
 }
 
 
index 7475416160198a57ac531b2341acaeee25b3f959..b1778808787158ecda829c584aaaf8e54454c70d 100644 (file)
@@ -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