From: Jürgen Vigna Date: Mon, 13 Aug 2001 11:04:49 +0000 (+0000) Subject: Fixed possible crash when reinitializing LyXText! X-Git-Tag: 1.6.10~20849 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f5394fd98263d6b2432359b632c4594cf1cf00ef;p=features.git Fixed possible crash when reinitializing LyXText! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2496 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 8fdb300624..3f8f4a0cf0 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,5 +1,9 @@ 2001-08-13 Juergen Vigna + * 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 diff --git a/src/insets/insettext.C b/src/insets/insettext.C index ea523df6ee..4c677b4ce1 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -129,7 +129,8 @@ InsetText::InnerCache::InnerCache(boost::shared_ptr 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()); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index e340437e9e..a654c47b1e 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -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