Abdelrazak Younes wrote:


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.
Updated patch attached.

Abdel.



Index: frontends/Dialogs.cpp
===================================================================
--- frontends/Dialogs.cpp       (revision 19080)
+++ frontends/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: frontends/Dialogs.h
===================================================================
--- frontends/Dialogs.h (revision 19080)
+++ frontends/Dialogs.h (working copy)
@@ -31,8 +31,6 @@
 public:
        ///
        Dialogs(LyXView &);
-       ///
-       ~Dialogs();
 
        /** Check the status of all visible dialogs and disable or reenable
         *  them as appropriate.
@@ -89,15 +87,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;
Index: insets/MailInset.cpp
===================================================================
--- insets/MailInset.cpp        (revision 19080)
+++ insets/MailInset.cpp        (working copy)
@@ -14,6 +14,7 @@
 
 #include "BufferView.h"
 #include "debug.h"
+#include "LyX.h"
 
 #include "frontends/Dialogs.h"
 
@@ -40,7 +41,7 @@
 
 void MailInset::hideDialog() const
 {
-       Dialogs::hide(name(), &inset());
+       LyX::cref().hideDialogs(name(), &inset());
 }
 
 
Index: LyX.cpp
===================================================================
--- LyX.cpp     (revision 19080)
+++ LyX.cpp     (working copy)
@@ -46,6 +46,7 @@
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
+#include "frontends/Dialogs.h"
 #include "frontends/Gui.h"
 #include "frontends/LyXView.h"
 
@@ -380,6 +381,17 @@
 }
 
 
+void LyX::hideDialogs(std::string const & name, Inset * inset) const
+{
+       vector<int> const & view_ids = pimpl_->application_->gui().viewIds();
+       vector<int>::const_iterator it = view_ids.begin();
+       vector<int>::const_iterator const end = view_ids.end();
+       for (; it != end; ++it)
+               pimpl_->application_->gui().view(*it).getDialogs().
+                       hide(name, inset);
+}
+
+
 int LyX::exec(int & argc, char * argv[])
 {
        // Here we need to parse the command line. At least
Index: LyX.h
===================================================================
--- LyX.h       (revision 19080)
+++ LyX.h       (working copy)
@@ -103,6 +103,8 @@
         */
        Buffer const * const updateInset(Inset const *) const;
 
+       void hideDialogs(std::string const & name, Inset * inset) const;
+
        /// Execute batch commands if available.
        void execBatchCommands();
 
Index: LyXFunc.cpp
===================================================================
--- LyXFunc.cpp (revision 19080)
+++ LyXFunc.cpp (working copy)
@@ -1374,7 +1374,7 @@
                }
 
                case LFUN_DIALOG_HIDE:
-                       Dialogs::hide(argument, 0);
+                       LyX::cref().hideDialogs(argument, 0);
                        break;
 
                case LFUN_DIALOG_TOGGLE: {
@@ -1841,7 +1841,7 @@
                        }
                }
        }
-       if (!quitting) {
+       if (!quitting && lyx_view_) {
                lyx_view_->updateMenubar();
                lyx_view_->updateToolbars();
                // Some messages may already be translated, so we cannot use _()

Reply via email to