Hi I like the patch too. And boost is a lot thinner now :)

Just to be sure: Yuriy do you plan to get rid of this signals2 namespace? It 
doe snot make much sense.


JMarc

Great! It is now only 1.5 MB!

Using "signals" conflicts with Qt keyword, so I've used "signal". Also moved now unneeded for signals class Trackable to the only place where it is used.


Yuriy

From c4d63765a338af4388a003afe015ff98e65b2c08 Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.ska...@gmail.com>
Date: Mon, 14 Dec 2020 20:46:39 +0200
Subject: [PATCH 1/5] Rename namespace signals2 -> signal

---
 src/LaTeX.h                        |  2 +-
 src/LyX.cpp                        | 20 ++++++++++----------
 src/graphics/GraphicsCacheItem.cpp |  4 ++--
 src/graphics/GraphicsCacheItem.h   |  4 ++--
 src/graphics/GraphicsConverter.cpp |  4 ++--
 src/graphics/GraphicsConverter.h   |  4 ++--
 src/graphics/GraphicsLoader.cpp    |  6 +++---
 src/graphics/GraphicsLoader.h      |  4 ++--
 src/graphics/PreviewLoader.cpp     |  4 ++--
 src/graphics/PreviewLoader.h       |  4 ++--
 src/insets/RenderPreview.cpp       |  2 +-
 src/insets/RenderPreview.h         |  6 +++---
 src/support/FileMonitor.cpp        |  2 +-
 src/support/FileMonitor.h          |  4 ++--
 src/support/ForkedCalls.h          |  2 +-
 src/support/Timeout.h              |  2 +-
 src/support/signals.h              |  2 +-
 17 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/LaTeX.h b/src/LaTeX.h
index 994fbe07ff..67e70de063 100644
--- a/src/LaTeX.h
+++ b/src/LaTeX.h
@@ -163,7 +163,7 @@ public:
        };
 
        /// This signal emits an informative message
-       signals2::signal<void(docstring)> message;
+       signal::signal<void(docstring)> message;
 
 
        /**
diff --git a/src/LyX.cpp b/src/LyX.cpp
index a0035fbe80..312e1277de 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -724,12 +724,12 @@ static void error_handler(int err_sig)
 
        // Deinstall the signal handlers
 #ifdef SIGHUP
-       signal(SIGHUP, SIG_DFL);
+       std::signal(SIGHUP, SIG_DFL);
 #endif
-       signal(SIGINT, SIG_DFL);
-       signal(SIGFPE, SIG_DFL);
-       signal(SIGSEGV, SIG_DFL);
-       signal(SIGTERM, SIG_DFL);
+       std::signal(SIGINT, SIG_DFL);
+       std::signal(SIGFPE, SIG_DFL);
+       std::signal(SIGSEGV, SIG_DFL);
+       std::signal(SIGTERM, SIG_DFL);
 
 #ifdef SIGHUP
        if (err_sig == SIGSEGV ||
@@ -852,12 +852,12 @@ static void initTemplatePath()
 bool LyX::init()
 {
 #ifdef SIGHUP
-       signal(SIGHUP, error_handler);
+       std::signal(SIGHUP, error_handler);
 #endif
-       signal(SIGFPE, error_handler);
-       signal(SIGSEGV, error_handler);
-       signal(SIGINT, error_handler);
-       signal(SIGTERM, error_handler);
+       std::signal(SIGFPE, error_handler);
+       std::signal(SIGSEGV, error_handler);
+       std::signal(SIGINT, error_handler);
+       std::signal(SIGTERM, error_handler);
        // SIGPIPE can be safely ignored.
 
 #if defined (USE_MACOSX_PACKAGING)
diff --git a/src/graphics/GraphicsCacheItem.cpp 
b/src/graphics/GraphicsCacheItem.cpp
index c72ac38659..384353b1fd 100644
--- a/src/graphics/GraphicsCacheItem.cpp
+++ b/src/graphics/GraphicsCacheItem.cpp
@@ -119,7 +119,7 @@ public:
        ImageStatus status_;
 
        /// This signal is emitted when the image loading status changes.
-       signals2::signal<void()> statusChanged;
+       signal::signal<void()> statusChanged;
 
        ///
        unique_ptr<Converter> converter_;
@@ -195,7 +195,7 @@ ImageStatus CacheItem::status() const
 }
 
 
-signals2::connection CacheItem::connect(slot_type const & slot) const
+signal::connection CacheItem::connect(slot_type const & slot) const
 {
        return pimpl_->statusChanged.connect(slot);
 }
diff --git a/src/graphics/GraphicsCacheItem.h b/src/graphics/GraphicsCacheItem.h
index ba5efe6b2a..143e30e621 100644
--- a/src/graphics/GraphicsCacheItem.h
+++ b/src/graphics/GraphicsCacheItem.h
@@ -81,9 +81,9 @@ public:
        /** Connect and you'll be informed when the loading status of the image
         *  changes.
         */
-       typedef signals2::signal<void()>::slot_type slot_type;
+       typedef signal::signal<void()>::slot_type slot_type;
        ///
-       signals2::connection connect(slot_type const &) const;
+       signal::connection connect(slot_type const &) const;
 
 private:
        /// noncopyable
diff --git a/src/graphics/GraphicsConverter.cpp 
b/src/graphics/GraphicsConverter.cpp
index 66e198ace4..2f1d1f9803 100644
--- a/src/graphics/GraphicsConverter.cpp
+++ b/src/graphics/GraphicsConverter.cpp
@@ -55,7 +55,7 @@ public:
        /** At the end of the conversion process inform the outside world
         *  by emitting a signal.
         */
-       typedef signals2::signal<void(bool)> sig;
+       typedef signal::signal<void(bool)> sig;
        ///
        sig finishedConversion;
 
@@ -96,7 +96,7 @@ void Converter::startConversion() const
 }
 
 
-signals2::connection Converter::connect(slot_type const & slot) const
+signal::connection Converter::connect(slot_type const & slot) const
 {
        return pimpl_->finishedConversion.connect(slot);
 }
diff --git a/src/graphics/GraphicsConverter.h b/src/graphics/GraphicsConverter.h
index 7eb3689ad1..d83894fb14 100644
--- a/src/graphics/GraphicsConverter.h
+++ b/src/graphics/GraphicsConverter.h
@@ -48,10 +48,10 @@ public:
         *  If the conversion is successful, then the listener is passed \c 
true.
         *  The connection is closed when this is destroyed.
         */
-       typedef signals2::signal<void(bool)> sig_type;
+       typedef signal::signal<void(bool)> sig_type;
        typedef sig_type::slot_type slot_type;
        ///
-       signals2::connection connect(slot_type const &) const;
+       signal::connection connect(slot_type const &) const;
 
        /** If the conversion is successful, this returns the name of the
         *  resulting file.
diff --git a/src/graphics/GraphicsLoader.cpp b/src/graphics/GraphicsLoader.cpp
index 2316a4ac69..a480c15668 100644
--- a/src/graphics/GraphicsLoader.cpp
+++ b/src/graphics/GraphicsLoader.cpp
@@ -192,9 +192,9 @@ public:
        /// We modify a local copy of the image once it is loaded.
        ImagePtr image_;
        /// This signal is emitted when the image loading status changes.
-       signals2::signal<void()> signal_;
+       signal::signal<void()> signal_;
        /// The connection of the signal statusChanged
-       signals2::scoped_connection connection_;
+       signal::scoped_connection connection_;
 
        double displayPixelRatio() const
        {
@@ -364,7 +364,7 @@ void Loader::setDisplayPixelRatio(double scale)
 }
 
 
-signals2::connection Loader::connect(slot const & slot) const
+signal::connection Loader::connect(slot const & slot) const
 {
        return pimpl_->signal_.connect(slot);
 }
diff --git a/src/graphics/GraphicsLoader.h b/src/graphics/GraphicsLoader.h
index 0a299cba1a..42b9f991ab 100644
--- a/src/graphics/GraphicsLoader.h
+++ b/src/graphics/GraphicsLoader.h
@@ -90,10 +90,10 @@ public:
        /** Connect and you'll be informed when the loading status of the image
         *  changes.
         */
-       typedef signals2::signal<void()> sig;
+       typedef signal::signal<void()> sig;
        typedef sig::slot_type slot;
        ///
-       signals2::connection connect(slot const &) const;
+       signal::connection connect(slot const &) const;
 
        /** The loaded image with Pixmap set.
         *  If the Pixmap is not yet set (see status() for why...), returns 0.
diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp
index e1177a8d87..a5bbe99bd4 100644
--- a/src/graphics/PreviewLoader.cpp
+++ b/src/graphics/PreviewLoader.cpp
@@ -180,7 +180,7 @@ public:
        void refreshPreviews();
 
        /// Emit this signal when an image is ready for display.
-       signals2::signal<void(PreviewImage const &)> imageReady;
+       signal::signal<void(PreviewImage const &)> imageReady;
 
        Buffer const & buffer() const { return buffer_; }
 
@@ -282,7 +282,7 @@ void PreviewLoader::refreshPreviews()
 }
 
 
-signals2::connection PreviewLoader::connect(slot const & slot) const
+signal::connection PreviewLoader::connect(slot const & slot) const
 {
        return pimpl_->imageReady.connect(slot);
 }
diff --git a/src/graphics/PreviewLoader.h b/src/graphics/PreviewLoader.h
index 5d0bf8e234..86b4c43c3e 100644
--- a/src/graphics/PreviewLoader.h
+++ b/src/graphics/PreviewLoader.h
@@ -76,10 +76,10 @@ public:
         *  has been created and is ready for loading through
         *  lyx::graphics::PreviewImage::image().
         */
-       typedef signals2::signal<void(PreviewImage const &)> sig;
+       typedef signal::signal<void(PreviewImage const &)> sig;
        typedef sig::slot_type slot;
        ///
-       signals2::connection connect(slot const &) const;
+       signal::connection connect(slot const &) const;
 
        /** When PreviewImage has finished loading the image file into memory,
         *  it tells the PreviewLoader to tell the outside world
diff --git a/src/insets/RenderPreview.cpp b/src/insets/RenderPreview.cpp
index 2ed69bb61f..9625d5be6b 100644
--- a/src/insets/RenderPreview.cpp
+++ b/src/insets/RenderPreview.cpp
@@ -288,7 +288,7 @@ void RenderMonitoredPreview::draw(PainterInfo & pi, int x, 
int y, bool const) co
 }
 
 
-signals2::connection RenderMonitoredPreview::connect(slot const & slot)
+signal::connection RenderMonitoredPreview::connect(slot const & slot)
 {
        return changed_.connect(slot);
 }
diff --git a/src/insets/RenderPreview.h b/src/insets/RenderPreview.h
index 97725d862d..a7baac063d 100644
--- a/src/insets/RenderPreview.h
+++ b/src/insets/RenderPreview.h
@@ -101,7 +101,7 @@ private:
        /** Store the connection to the preview loader so that we connect
         *  only once.
         */
-       signals2::scoped_connection ploader_connection_;
+       signal::scoped_connection ploader_connection_;
 
        /// Inform the core that the inset has changed.
        Inset const * parent_;
@@ -122,9 +122,9 @@ public:
 
        /// Connect and you'll be informed when the file changes.
        /// Do not forget to track objects used by the slot.
-       typedef signals2::signal<void()> sig;
+       typedef signal::signal<void()> sig;
        typedef sig::slot_type slot;
-       signals2::connection connect(slot const & slot);
+       signal::connection connect(slot const & slot);
 
        /// equivalent to dynamic_cast
        RenderMonitoredPreview * asMonitoredPreview() override { return this; }
diff --git a/src/support/FileMonitor.cpp b/src/support/FileMonitor.cpp
index a3b17ad012..8e97f3ba5b 100644
--- a/src/support/FileMonitor.cpp
+++ b/src/support/FileMonitor.cpp
@@ -188,7 +188,7 @@ void FileMonitor::connectToFileMonitorGuard()
 }
 
 
-signals2::connection FileMonitor::connect(slot const & slot)
+signal::connection FileMonitor::connect(slot const & slot)
 {
        return fileChanged_.connect(slot);
 }
diff --git a/src/support/FileMonitor.h b/src/support/FileMonitor.h
index 622637efa4..ca736f5fad 100644
--- a/src/support/FileMonitor.h
+++ b/src/support/FileMonitor.h
@@ -130,10 +130,10 @@ class FileMonitor : public QObject
 public:
        FileMonitor(std::shared_ptr<FileMonitorGuard> monitor);
 
-       typedef signals2::signal<void(bool)> sig;
+       typedef signal::signal<void(bool)> sig;
        typedef sig::slot_type slot;
        /// Connect and you'll be informed when the file has changed.
-       signals2::connection connect(slot const &);
+       signal::connection connect(slot const &);
        /// absolute path being tracked
        std::string const & filename() { return monitor_->filename(); }
        /// Make sure the good file is being monitored, after e.g. a move or a
diff --git a/src/support/ForkedCalls.h b/src/support/ForkedCalls.h
index 681b88965d..7553342499 100644
--- a/src/support/ForkedCalls.h
+++ b/src/support/ForkedCalls.h
@@ -53,7 +53,7 @@ public:
         *  we can return easily to C++ methods, rather than just globally
         *  accessible functions.
         */
-       typedef signals2::signal<void(pid_t, int)> sig;
+       typedef signal::signal<void(pid_t, int)> sig;
        typedef sig::slot_type slot;
 
        /** The signal is connected in the calling routine to the desired
diff --git a/src/support/Timeout.h b/src/support/Timeout.h
index eef78dbec6..ae0d183805 100644
--- a/src/support/Timeout.h
+++ b/src/support/Timeout.h
@@ -40,7 +40,7 @@ public:
        /// restart the timer
        void restart();
        /// signal emitted on timer expiry
-       signals2::signal<void()> timeout;
+       signal::signal<void()> timeout;
        /// emit the signal
        void emit();
        /// set the timer type
diff --git a/src/support/signals.h b/src/support/signals.h
index ceca3709c6..a16899909f 100644
--- a/src/support/signals.h
+++ b/src/support/signals.h
@@ -18,7 +18,7 @@
 
 namespace lyx {
 
-namespace signals2 = ::nod;
+namespace signal = ::nod;
 
 namespace support {
 
-- 
2.28.0.windows.1

From 6614835d17db44280d662152681fe5f6da56c40c Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.ska...@gmail.com>
Date: Tue, 15 Dec 2020 09:25:28 +0200
Subject: [PATCH 2/5] Remove useless declaration

---
 src/support/Timeout.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/support/Timeout.h b/src/support/Timeout.h
index ae0d183805..d2af8c5b46 100644
--- a/src/support/Timeout.h
+++ b/src/support/Timeout.h
@@ -55,8 +55,6 @@ private:
        ///
        class Impl;
        ///
-       friend class Impl;
-       ///
        Impl * const pimpl_;
        /// one-shot or repeating
        Type type;
-- 
2.28.0.windows.1

From cea564ee57a81936f7a0b646705140f523fda61a Mon Sep 17 00:00:00 2001
From: Yuriy Skalko <yuriy.ska...@gmail.com>
Date: Wed, 16 Dec 2020 12:07:42 +0200
Subject: [PATCH 4/5] Move Trackable class to Server.h

---
 src/Server.cpp        |  1 -
 src/Server.h          | 20 +++++++++++++++++---
 src/support/signals.h | 26 --------------------------
 3 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/src/Server.cpp b/src/Server.cpp
index 8d9e0c61db..6549228536 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -55,7 +55,6 @@
 #include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/os.h"
-#include "support/signals.h"
 
 #include <iostream>
 
diff --git a/src/Server.h b/src/Server.h
index b277284ace..2f26b8aef7 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -14,8 +14,7 @@
 #ifndef SERVER_H
 #define SERVER_H
 
-#include "support/signals.h"
-
+#include <memory>
 #include <vector>
 
 #ifdef _WIN32
@@ -30,6 +29,21 @@ namespace lyx {
 class Server;
 
 
+/// A small utility to track the lifetime of an object.
+class Trackable {
+public:
+       Trackable() : p_(std::make_shared<int>(0)) {}
+       Trackable(Trackable const &) : Trackable() {}
+       Trackable(Trackable &&) : Trackable() {}
+       Trackable & operator=(Trackable const &) { return *this; }
+       Trackable & operator=(Trackable &&) { return *this; }
+       // This weak pointer lets you know if the parent object has been 
destroyed
+       std::weak_ptr<void> p() const { return p_; }
+private:
+       std::shared_ptr<void> const p_;
+};
+
+
 /** This class manages the pipes used for communicating with clients.
  Usage: Initialize with pipe-filename-base, client class to receive
  messages, and callback-function that will be called with the messages.
@@ -191,7 +205,7 @@ private:
        bool deferred_loading_;
 
        /// Track object's liveness
-       support::Trackable tracker_;
+       Trackable tracker_;
 };
 
 
diff --git a/src/support/signals.h b/src/support/signals.h
index a16899909f..75af4dd847 100644
--- a/src/support/signals.h
+++ b/src/support/signals.h
@@ -14,36 +14,10 @@
 
 #include <nod.hpp>
 
-#include <memory>
-
 namespace lyx {
 
 namespace signal = ::nod;
 
-namespace support {
-
-/// A small utility to use with signals2::slot_type::track_foreign when the
-/// parent object is not handled by a shared_ptr, or to track the lifetime of 
an
-/// object. Using Trackable to track lifetimes is less thread-safe than 
tracking
-/// their parents directly with a shared_ptr as recommended by signals2, but it
-/// makes it easier for transitioning old code. (Essentially because Trackable
-/// will not prevent the deletion of the parent by a concurrent thread.)
-class Trackable {
-public:
-       Trackable() : p_(std::make_shared<int>(0)) {}
-       Trackable(Trackable const &) : Trackable() {}
-       Trackable(Trackable &&) : Trackable() {}
-       Trackable & operator=(Trackable const &) { return *this; }
-       Trackable & operator=(Trackable &&) { return *this; }
-       // This weak pointer lets you know if the parent object has been 
destroyed
-       std::weak_ptr<void> p() const { return p_; }
-private:
-       std::shared_ptr<void> const p_;
-};
-
-} // namespace support
-
 } // namespace lyx
 
-
 #endif
-- 
2.28.0.windows.1

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to