Bo Peng wrote:
On 5/30/07, Bo Peng <[EMAIL PROTECTED]>
wrote:
> >> I find that removal of every collapsable inset leads to crash.
Must be
> >> something that is introduced recently.
Abdel,
It is suspected that your destroyed() signal crashes lyx in this case,
maybe a problem with my gcc 3.4.6. I remember that a similar crash
that is only reproducible on gcc 3.4 was fixed by adding disconnect()
somewhere a while ago. Maybe this is the case again.
Possibly yes. I have a patch pending for that issue that is not OKed
AFAIS. Could you try it?
Abdel.
Index: CursorSlice.cpp
===================================================================
--- CursorSlice.cpp (revision 18579)
+++ CursorSlice.cpp (working copy)
@@ -42,7 +42,9 @@
: inset_(&p), idx_(0), pit_(0), pos_(0)
{
BOOST_ASSERT(inset_);
- inset_->destroyed.connect(
+ boost::signal<void()> * destroyed_signal = inset_->destroyedSignal();
+ if (destroyed_signal)
+ inset_connection_ = destroyed_signal->connect(
boost::bind(&CursorSlice::invalidate, this));
}
@@ -52,16 +54,20 @@
operator=(cs);
}
+CursorSlice::~CursorSlice()
+{
+ inset_connection_.disconnect();
+}
+
CursorSlice & CursorSlice::operator=(CursorSlice const & cs)
{
inset_ = cs.inset_;
idx_ = cs.idx_;
pit_ = cs.pit_;
pos_ = cs.pos_;
- if (inset_) {
- BOOST_ASSERT(inset_);
- inset_->destroyed.connect(
+ if (inset_ && inset_->destroyedSignal()) {
+ inset_connection_ = inset_->destroyedSignal()->connect(
boost::bind(&CursorSlice::invalidate, this));
}
return *this;
Index: CursorSlice.h
===================================================================
--- CursorSlice.h (revision 18579)
+++ CursorSlice.h (working copy)
@@ -63,6 +63,7 @@
///
explicit CursorSlice(Inset &);
///
+ virtual ~CursorSlice();
CursorSlice & operator=(CursorSlice const &);
///
bool isValid() const;
@@ -156,6 +157,8 @@
bool pit_valid_;
/// position in this cell
pos_type pos_;
+ /// connection to referred \c inset_ destruction signal.
+ boost::signals::connection inset_connection_;
};
/// test for equality
Index: insets/Inset.cpp
===================================================================
--- insets/Inset.cpp (revision 18579)
+++ insets/Inset.cpp (working copy)
@@ -121,19 +121,6 @@
{}
-Inset::Inset(Inset const & inset)
- : dim_(inset.dim_), background_color_(inset.background_color_)
-{}
-
-
-Inset & Inset::operator=(Inset const & inset)
-{
- dim_ = inset.dim_;
- background_color_ = inset.background_color_;
- return *this;
-}
-
-
std::auto_ptr<Inset> Inset::clone() const
{
std::auto_ptr<Inset> b = doClone();
Index: insets/Inset.h
===================================================================
--- insets/Inset.h (revision 18579)
+++ insets/Inset.h (working copy)
@@ -72,7 +72,7 @@
typedef size_t col_type;
/// virtual base class destructor
- virtual ~Inset() { destroyed();}
+ virtual ~Inset() {}
/// replicate ourselves
std::auto_ptr<Inset> clone() const;
@@ -477,14 +477,15 @@
//
enum { TEXT_TO_INSET_OFFSET = 4 };
- /// This signal is emitted when the inset is destroyed.
- boost::signal<void()> destroyed;
+ /// Signal for inset destruction.
+ /** This signal is emitted at the inset destruction for insets that
+ * support this.
+ */
+ virtual boost::signal<void()> * destroyedSignal() { return 0; }
protected:
Inset();
- Inset(Inset const & i);
- ///
- Inset & operator=(Inset const &);
+
/** The real dispatcher.
* Gets normally called from Cursor::dispatch(). Cursor::dispatch()
* assumes the common case of 'LFUN handled, need update'.
Index: insets/InsetText.cpp
===================================================================
--- insets/InsetText.cpp (revision 18579)
+++ insets/InsetText.cpp (working copy)
@@ -51,6 +51,7 @@
#include <boost/bind.hpp>
#include <boost/current_function.hpp>
+#include <boost/signal.hpp>
#include <sstream>
Index: insets/InsetText.h
===================================================================
--- insets/InsetText.h (revision 18579)
+++ insets/InsetText.h (working copy)
@@ -42,6 +42,8 @@
explicit InsetText(BufferParams const &);
///
InsetText();
+ ///
+ virtual ~InsetText() { destroyed(); }
/// empty inset to empty par
void clear();
@@ -138,6 +140,8 @@
virtual bool wide() const { return wide_inset_; }
///
void setWide(bool wide_inset) { wide_inset_ = wide_inset; }
+ ///
+ boost::signal<void()> * destroyedSignal() { return &destroyed; }
protected:
///
@@ -159,6 +163,9 @@
mutable pit_type old_pit;
///
bool wide_inset_;
+ /// This signal is emitted when the inset is destroyed.
+ boost::signal<void()> destroyed;
+
public:
///
mutable Text text_;
Index: mathed/InsetMathNest.cpp
===================================================================
--- mathed/InsetMathNest.cpp (revision 18579)
+++ mathed/InsetMathNest.cpp (working copy)
@@ -78,6 +78,20 @@
{}
+InsetMathNest::InsetMathNest(InsetMathNest const & inset)
+ : InsetMath(inset), cells_(inset.cells_), lock_(inset.lock_)
+{}
+
+
+InsetMathNest & InsetMathNest::operator=(InsetMathNest const & inset)
+{
+ cells_ = inset.cells_;
+ lock_ = inset.lock_;
+ InsetMath::operator=(inset);
+ return *this;
+}
+
+
InsetMath::idx_type InsetMathNest::nargs() const
{
return cells_.size();
Index: mathed/InsetMathNest.h
===================================================================
--- mathed/InsetMathNest.h (revision 18579)
+++ mathed/InsetMathNest.h (working copy)
@@ -27,6 +27,8 @@
public:
/// nestinsets have a fixed size to start with
explicit InsetMathNest(idx_type ncells);
+ ///
+ virtual ~InsetMathNest() { destroyed(); }
/// the size is usually some sort of convex hull of the cells
/// hides inset::metrics() intentionally!
@@ -104,8 +106,16 @@
int latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const;
+ /// This signal is emitted when the inset is destroyed.
+ boost::signal<void()> * destroyedSignal() { return &destroyed; }
+
protected:
///
+ InsetMathNest(InsetMathNest const & inset);
+ ///
+ InsetMathNest & operator=(InsetMathNest const &);
+
+ ///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
/// do we want to handle this event?
bool getStatus(Cursor & cur, FuncRequest const & cmd,
@@ -146,6 +156,10 @@
cells_type cells_;
/// if the inset is locked, it can't be entered with the cursor
bool lock_;
+
+private:
+ /// This signal is emitted when the inset is destroyed.
+ boost::signal<void()> destroyed;
};