Abdelrazak Younes wrote:
Abdelrazak Younes wrote:
Andre Poenitz wrote:
On Tue, Oct 02, 2007 at 08:11:47AM +0200, Abdelrazak Younes wrote:
Andre Poenitz wrote:
The attached patch replaces the signal/slot connections between Buffer
and BufferView to LyXView by ordinary delegates.

There has always been only (at most) a single connection of each type
with known endpoints, so full-blown signal/slot was overkill anyway -
I am sorry but that's not true for Buffer. With multi-workarea and multi-view there can be more than one connection to the Buffer::changed() signal.

The signal was only attached to the LyXView, not to the workarea.

Wrong, in WorkArea.h:

    /// buffer changed signal connection
    boost::signals::connection bufferChangedConnection_;
    /// buffer closing signal connection
    boost::signals::connection bufferClosingConnection_;

I did not change the structure of the code.

You did a bit I'm afraid.

OK, if we continue with your patch except for those two signals, one solution would be to have a WorkareaManager:

And here is the beginning of a patch. If you could take it and finish the remaining bits together with your patch, you'd make me very happy.

Abdel.

Index: Buffer.cpp
===================================================================
--- Buffer.cpp  (revision 20651)
+++ Buffer.cpp  (working copy)
@@ -68,6 +68,7 @@
 #include "mathed/MathSupport.h"
 
 #include "frontends/alert.h"
+#include "frontends/WorkAreaManager.h"
 
 #include "graphics/Previews.h"
 
@@ -206,13 +207,17 @@
        /// modified. (Used to properly enable 'File->Revert to saved', bug 
4114).
        time_t timestamp_;
        unsigned long checksum_;
+
+       ///
+       frontend::WorkAreaManager * wa_;
 };
 
 
 Buffer::Impl::Impl(Buffer & parent, FileName const & file, bool readonly_)
        : lyx_clean(true), bak_clean(true), unnamed(false), 
read_only(readonly_),
          filename(file), file_fully_loaded(false), inset(params),
-         toc_backend(&parent), embedded_files(&parent), timestamp_(0), 
checksum_(0)
+         toc_backend(&parent), embedded_files(&parent), timestamp_(0),
+         checksum_(0), wa_(0)
 {
        inset.setAutoBreakRows(true);
        lyxvc.buffer(&parent);
@@ -221,6 +226,9 @@
        // FIXME: And now do something if temppath == string(), because we
        // assume from now on that temppath points to a valid temp dir.
        // See http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg67406.html
+
+       if (use_gui)
+               wa_ = new frontend::WorkAreaManager;
 }
 
 
@@ -253,10 +261,18 @@
        // Remove any previewed LaTeX snippets associated with this buffer.
        graphics::Previews::get().removeLoader(*this);
 
-       closing(this);
+       if (pimpl_->wa_)
+               pimpl_->wa_->closing();
 }
 
 
+void Buffer::changed()
+{
+       if (pimpl_->wa_)
+               pimpl_->wa_->changed();
+}
+
+
 Text & Buffer::text() const
 {
        return const_cast<Text &>(pimpl_->inset.text_);
Index: frontends/WorkAreaManager.h
===================================================================
--- frontends/WorkAreaManager.h (revision 0)
+++ frontends/WorkAreaManager.h (revision 0)
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+/**
+ * \file WorkAreaManager.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef WORKAREA_MANAGER_H
+#define WORKAREA_MANAGER_H
+
+#include "WorkArea.h"
+
+namespace lyx {
+namespace frontend {
+
+class WorkAreaManager
+{
+public:
+       WorkAreaManager() {}
+
+       register(WorkArea * wa)
+       {
+               work_areas_.push_back(wa);
+       }
+
+       changed()
+       {
+               for (size_t i = 0; i != work_areas_.size(); ++i)
+                       work_areas_[i]->redraw();
+       }
+
+       closing()
+       {
+               for (size_t i = 0; i != work_areas_.size(); ++i)
+                       work_areas_[i]->close();
+       }
+
+private:
+       std::vector<WorkArea *> work_areas_;
+} 
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // BASE_WORKAREA_H

Property changes on: frontends\WorkAreaManager.h
___________________________________________________________________
Name: svn:eol-style
   + native

Reply via email to