Bernhard Roider schrieb:
Bernhard Roider schrieb:
Hello,
there is a crash and i can tell the reason. As i have no time
investigate further i post to the list what i already found out.
to reproduce:
1. start lyx
2. open a document that contains insets
3. open another window (new window)
4. close the second window
5. close the document in the first window -> crash (sometimes)
the reason:
- in step 3 an instance of class Dialog is created for the second window
- in step 4 this instance is deleted again
- in step 5 the signal hideSlot is sent to the already deleted dialog.
This sometimes gives a segfault.
the reason is easy to verify from debug output if you apply the
attached patch.
I think it's again a missing disconnect() somewhere.
It's late but i found half an hour to investigate and read some boost
signal docs. Here's a solution that works: From the (new) Dialog
destructor disconnect the hide signal.
Objections?
Bernhard
This patch leaves the comments where they should be...
Index: src/frontends/Dialogs.cpp
===================================================================
--- src/frontends/Dialogs.cpp (revision 18672)
+++ src/frontends/Dialogs.cpp (working copy)
@@ -71,9 +71,12 @@
: lyxview_(lyxview), in_show_(false)
{
// Connect signals
- hideSignal().connect(boost::bind(&Dialogs::hideSlot, this, _1, _2));
+ connection_ = hideSignal().connect(boost::bind(&Dialogs::hideSlot,
this, _1, _2));
}
+Dialogs::~Dialogs() {
+ connection_.disconnect();
+}
Dialog * Dialogs::find_or_build(string const & name)
{
Index: src/frontends/Dialogs.h
===================================================================
--- src/frontends/Dialogs.h (revision 18672)
+++ src/frontends/Dialogs.h (working copy)
@@ -31,6 +31,8 @@
public:
///
Dialogs(LyXView &);
+ ///
+ ~Dialogs();
/** Check the status of all visible dialogs and disable or reenable
* them as appropriate.
@@ -116,6 +118,9 @@
/// flag against a race condition due to multiclicks in Qt frontend,
see bug #1119
bool in_show_;
+
+ ///
+ boost::signals::connection connection_;
};
} // namespace lyx