]> git.lyx.org Git - features.git/commitdiff
Fixed possible crash when reinitializing LyXText!
authorJürgen Vigna <jug@sad.it>
Mon, 13 Aug 2001 11:04:49 +0000 (11:04 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 13 Aug 2001 11:04:49 +0000 (11:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2496 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insettext.C
src/insets/insettext.h

index 8fdb300624435fb261193c6239eeb7b69f774f63..3f8f4a0cf0ada64a58b32c7e8799428acd2e2465 100644 (file)
@@ -1,5 +1,9 @@
 2001-08-13  Juergen Vigna  <jug@sad.it>
 
+       * insettext.C: fixed problem when reinitializing LyXText by not doing
+       it while lt is in use and post this to the next possible time in
+       getLyXText().
+
        * insetert.C (InsetERT): init status_ also in the 3rd constructor.
 
        * insettabular.C (tabularFeatures): fixed fix where deleting the
index ea523df6eed4efc2632aeee369fe2b58d49beb24..4c677b4ce1254474208f263b2b333bfc1f88e153 100644 (file)
@@ -129,7 +129,8 @@ InsetText::InnerCache::InnerCache(boost::shared_ptr<LyXText> t)
 
 
 InsetText::InsetText()
-       : UpdatableInset(), lt(0), in_update(false)
+       : UpdatableInset(), lt(0), in_update(false), do_resize(0),
+         do_reinit(false)
 {
        par = new Paragraph;
        init();
@@ -137,7 +138,8 @@ InsetText::InsetText()
 
 
 InsetText::InsetText(InsetText const & in, bool same_id)
-       : UpdatableInset(in, same_id), lt(0), in_update(false)
+       : UpdatableInset(in, same_id), lt(0), in_update(false), do_resize(0),
+         do_reinit(false)
 {
        par = 0;
        init(&in, same_id);
@@ -1851,7 +1853,7 @@ Row * InsetText::crow(BufferView * bv) const
 
 
 LyXText * InsetText::getLyXText(BufferView const * lbv,
-                                         bool const recursive) const
+                                bool const recursive) const
 {
        if (!recursive && (cached_bview == lbv))
                return cached_text.get();
@@ -1863,6 +1865,10 @@ LyXText * InsetText::getLyXText(BufferView const * lbv,
        Cache::iterator it = cache.find(bv);
 
        if (it != cache.end()) {
+               if (do_reinit)
+                       reinitLyXText();
+               else if (do_resize)
+                       resizeLyXText(do_resize);
                if (lt || !it->second.remove) {
                        lyx::Assert(it->second.text.get());
                        cached_text = it->second.text;
@@ -1917,6 +1923,13 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
 
 void InsetText::resizeLyXText(BufferView * bv, bool force) const
 {
+       if (lt) {
+               // we cannot resize this because we are in use!
+               // so do this on the next possible getLyXText()
+               do_resize = bv;
+               return;
+       }
+       do_resize = false;
 //     lyxerr << "InsetText::resizeLyXText\n";
        if (!par->next() && !par->size()) // no data, resize not neccessary!
                return;
@@ -1957,6 +1970,14 @@ void InsetText::resizeLyXText(BufferView * bv, bool force) const
 
 void InsetText::reinitLyXText() const
 {
+       if (lt) {
+               // we cannot resize this because we are in use!
+               // so do this on the next possible getLyXText()
+               do_reinit = true;
+               return;
+       }
+       do_reinit = false;
+       do_resize = false;
 //     lyxerr << "InsetText::reinitLyXText\n";
        for(Cache::iterator it = cache.begin(); it != cache.end(); ++it) {
                lyx::Assert(it->second.text.get());
index e340437e9e39b66456acdef2bf98bef87c5f9725..a654c47b1e507ecf23a52143a27acb5560e43daf 100644 (file)
@@ -397,5 +397,7 @@ private:
        mutable int frame_h;
        ///
        bool in_update; /* as update is not reentrant! */
+       mutable BufferView * do_resize;
+       mutable bool do_reinit;
 };
 #endif