Abdelrazak Younes wrote:
Abdelrazak Younes wrote:
Peter Kümmel wrote:
Abdelrazak Younes wrote:
Peter Kümmel wrote:
Yes, this could be. We should simply NOT use the static solution.
Does attached patch work on Debian? If yes we could remove
BugfixSignal, and
create the signal at runtime. But we then have to clean up correctly.
Your solution will only work with the first instance...

Abdel.


I don't understand. The only problem I see is the memory leak because of not
deleting hideSignal.

The hideSignal must not be shared between multiple Dialogs instance (as will be the case with multiple views).

The only solution is just to get rid of this BugfixSignal. Actually, this hideSignal is not needed at all!

Something like the attached. I guess this signal was needed at some point but not anymore.

Abdel.
Index: Dialogs.cpp
===================================================================
--- Dialogs.cpp (revision 19080)
+++ Dialogs.cpp (working copy)
@@ -21,63 +21,18 @@
 #include <boost/signal.hpp>
 #include <boost/bind.hpp>
 
+using std::string;
 
 namespace lyx {
 
-
-using std::string;
 using lyx::frontend::Dialog;
 
 
-// Note that static boost signals break some compilers, so this wrapper
-// initialises the signal dynamically when it is first invoked.
-template<typename Signal>
-class BugfixSignal {
-public:
-       Signal & operator()() { return thesignal(); }
-       Signal const & operator()() const { return thesignal(); }
-
-private:
-       Signal & thesignal() const
-       {
-               if (!signal_.get())
-                       signal_.reset(new Signal);
-               return *signal_;
-       }
-
-       mutable boost::scoped_ptr<Signal> signal_;
-};
-
-
-namespace {
-
-BugfixSignal<boost::signal<void(string const &, Inset*)> > hideSignal;
-
-}
-
-
-void Dialogs::hide(string const & name, Inset* inset)
-{
-       // Don't send the signal if we are quitting, because on MSVC it is
-       // destructed before the cut stack in CutAndPaste.cpp, and this method
-       // is called from some inset destructor if the cut stack is not empty
-       // on exit.
-       if (!quitting)
-               hideSignal()(name, inset);
-}
-
-
 Dialogs::Dialogs(LyXView & lyxview)
        : lyxview_(lyxview), in_show_(false)
 {
-       // Connect signals
-       connection_ = hideSignal().connect(boost::bind(&Dialogs::hideSlot, 
this, _1, _2));
 }
 
-Dialogs::~Dialogs() 
-{
-       connection_.disconnect();
-}
 
 Dialog * Dialogs::find_or_build(string const & name)
 {
@@ -149,8 +104,15 @@
 }
 
 
-void Dialogs::hideSlot(string const & name, Inset * inset)
+void Dialogs::hide(string const & name, Inset* inset)
 {
+       // Don't send the signal if we are quitting, because on MSVC it is
+       // destructed before the cut stack in CutAndPaste.cpp, and this method
+       // is called from some inset destructor if the cut stack is not empty
+       // on exit.
+       if (quitting)
+               return;
+
        std::map<string, DialogPtr>::const_iterator it =
                dialogs_.find(name);
        if (it == dialogs_.end())
Index: Dialogs.h
===================================================================
--- Dialogs.h   (revision 19080)
+++ Dialogs.h   (working copy)
@@ -89,15 +89,13 @@
        /** All Dialogs of the given \param name will be closed if they are
            connected to the given \param inset.
        */
-       static void hide(std::string const & name, Inset * inset);
+       void hide(std::string const & name, Inset * inset);
        ///
        void disconnect(std::string const & name);
        ///
        Inset * getOpenInset(std::string const & name) const;
 private:
        ///
-       void hideSlot(std::string const & name, Inset * inset);
-       ///
        void redraw() const;
        ///
        bool isValidName(std::string const & name) const;

Reply via email to