]> git.lyx.org Git - features.git/commitdiff
Fix this bug:
authorAbdelrazak Younes <younes@lyx.org>
Tue, 17 Jul 2007 09:20:39 +0000 (09:20 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 17 Jul 2007 09:20:39 +0000 (09:20 +0000)
1) create a doc
2) insert an ert inset
3) right-click the inset
4) new window
5) delete the ert inset: BOOM!

This commit replace the static hideDialog signal which was in effect shared by all views with a direct call to Dialog::hide().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19094 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyX.cpp
src/LyX.h
src/LyXFunc.cpp
src/frontends/Dialogs.cpp
src/frontends/Dialogs.h
src/insets/MailInset.cpp

index 9bbf03faea9aa5a9fd58ef816eb31dfd7bffab94..f4ef3a87b835303a343fe26093714dc32cd9c011 100644 (file)
@@ -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 @@ Buffer const * const LyX::updateInset(Inset const * inset) const
 }
 
 
+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 efd82fd83f2809c0fbfbb5d3b8c23560b04f4f5b..b39ab729f0629252f71445c1222b04b904139313 100644 (file)
--- a/src/LyX.h
+++ b/src/LyX.h
@@ -103,6 +103,8 @@ public:
         */
        Buffer const * const updateInset(Inset const *) const;
 
+       void hideDialogs(std::string const & name, Inset * inset) const;
+
        /// Execute batch commands if available.
        void execBatchCommands();
 
index b753551211f418c5e647a8e0267790457f3d1682..d96ed513ae5e3feb37c04bff460ed4c39faf2166 100644 (file)
@@ -1374,7 +1374,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                }
 
                case LFUN_DIALOG_HIDE:
-                       Dialogs::hide(argument, 0);
+                       LyX::cref().hideDialogs(argument, 0);
                        break;
 
                case LFUN_DIALOG_TOGGLE: {
@@ -1841,7 +1841,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        }
                }
        }
-       if (!quitting) {
+       if (!quitting && lyx_view_) {
                lyx_view_->updateMenubar();
                lyx_view_->updateToolbars();
                // Some messages may already be translated, so we cannot use _()
index a95950c7849126cb24238738bcf8b26a5923e079..0f89d05851bfec2a92bf5c21f55e1ee80a621fdd 100644 (file)
 #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::update(string const & name, string const & data)
 }
 
 
-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 a81b7536a7a51249f351db110d5ffd5095bb48e9..f179ec56d71e0b3fddc5dc7689e3c52a9bc8fd4b 100644 (file)
@@ -31,8 +31,6 @@ class Dialogs : boost::noncopyable {
 public:
        ///
        Dialogs(LyXView &);
-       ///
-       ~Dialogs();
 
        /** Check the status of all visible dialogs and disable or reenable
         *  them as appropriate.
@@ -89,14 +87,12 @@ public:
        /** 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;
        ///
index 964228a9237b089474dd621399234cea210b0b17..1ee4a345715fc55a6d37caf4c8f217cdc62e4770 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "BufferView.h"
 #include "debug.h"
+#include "LyX.h"
 
 #include "frontends/Dialogs.h"
 
@@ -40,7 +41,7 @@ void MailInset::updateDialog(BufferView * bv) const
 
 void MailInset::hideDialog() const
 {
-       Dialogs::hide(name(), &inset());
+       LyX::cref().hideDialogs(name(), &inset());
 }