File: 70-boost-causing-ftbfs-signal2-part1.patch

package info (click to toggle)
boost1.83 1.83.0-4.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 545,456 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (128 lines) | stat: -rw-r--r-- 5,534 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
From 2ba258f7b465e7bde14663ca3a966019b4ec3694 Mon Sep 17 00:00:00 2001
From: Frank Mori Hess <fmh6jj@gmail.com>
Date: Sat, 30 Dec 2023 14:34:58 -0500
Subject: [PATCH] Fix disconnect by slot when the slot is another signal.

---
 .../boost/signals2/detail/signal_template.hpp | 48 +++++++++++++++----
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/libs/signals2/include/boost/signals2/detail/signal_template.hpp b/include/boost/signals2/detail/signal_template.hpp
index a399883c..4546906d 100644
--- a/libs/signals2/include/boost/signals2/detail/signal_template.hpp
+++ b/libs/signals2/include/boost/signals2/detail/signal_template.hpp
@@ -103,9 +103,9 @@ namespace boost
               BOOST_SIGNALS2_FORWARDED_ARGS(BOOST_SIGNALS2_NUM_ARGS));
         }
         template<typename T>
-          bool operator==(const T &other) const
+          bool contains(const T &other) const
         {
-          return _fun == other;
+          return _fun.contains(other);
         }
       private:
         BOOST_SIGNALS2_BOUND_EXTENDED_SLOT_FUNCTION_N(BOOST_SIGNALS2_NUM_ARGS)()
@@ -115,6 +115,8 @@ namespace boost
         boost::shared_ptr<connection> _connection;
       };
 
+      template<BOOST_SIGNALS2_SIGNAL_TEMPLATE_DECL(BOOST_SIGNALS2_NUM_ARGS)>
+        class BOOST_SIGNALS2_WEAK_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS);
       template<BOOST_SIGNALS2_SIGNAL_TEMPLATE_DECL(BOOST_SIGNALS2_NUM_ARGS)>
         class BOOST_SIGNALS2_SIGNAL_IMPL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS);
 
@@ -150,6 +152,8 @@ namespace boost
         typedef GroupCompare group_compare_type;
         typedef typename detail::slot_call_iterator_t<slot_invoker,
           typename connection_list_type::iterator, connection_body<group_key_type, slot_type, Mutex> > slot_call_iterator;
+        typedef detail::BOOST_SIGNALS2_WEAK_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
+          <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> weak_signal_type;
 
         BOOST_SIGNALS2_SIGNAL_IMPL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)(const combiner_type &combiner_arg,
           const group_compare_type &group_compare):
@@ -531,13 +535,20 @@ namespace boost
             {
               (*it)->nolock_disconnect(lock);
             }else
-            {
-              // check for wrapped extended slot
+            { // check for wrapped extended slot
               bound_extended_slot_function_type *fp;
               fp = (*it)->slot().slot_function().template target<bound_extended_slot_function_type>();
-              if(fp && function_equal(*fp, slot))
+              if(fp && fp->contains(slot))
               {
                 (*it)->nolock_disconnect(lock);
+              }else
+              { // check for wrapped signal
+                weak_signal_type *fp;
+                fp = (*it)->slot().slot_function().template target<weak_signal_type>();
+                if(fp && fp->contains(slot))
+                {
+                  (*it)->nolock_disconnect(lock);
+                }
               }
             }
           }
@@ -588,8 +599,6 @@ namespace boost
         const boost::shared_ptr<mutex_type> _mutex;
       };
 
-      template<BOOST_SIGNALS2_SIGNAL_TEMPLATE_DECL(BOOST_SIGNALS2_NUM_ARGS)>
-        class BOOST_SIGNALS2_WEAK_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS);
     }
 
     template<BOOST_SIGNALS2_SIGNAL_TEMPLATE_DEFAULTED_DECL(BOOST_SIGNALS2_NUM_ARGS)>
@@ -603,8 +612,7 @@ namespace boost
       typedef detail::BOOST_SIGNALS2_SIGNAL_IMPL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
         <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> impl_class;
     public:
-      typedef detail::BOOST_SIGNALS2_WEAK_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
-        <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> weak_signal_type;
+      typedef typename impl_class::weak_signal_type weak_signal_type;
       friend class detail::BOOST_SIGNALS2_WEAK_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
         <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION>;
 
@@ -746,12 +754,24 @@ namespace boost
         using std::swap;
         swap(_pimpl, other._pimpl);
       }
+      bool operator==(const BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS) & other) const
+      {
+        return _pimpl.get() == other._pimpl.get();
+      }
     protected:
       virtual shared_ptr<void> lock_pimpl() const
       {
         return _pimpl;
       }
     private:
+      // explicit private copy constructor to avoid compiler trying to do implicit conversions to signal
+      explicit BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)(
+        const BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS) & other) BOOST_NOEXCEPT
+      {
+          // noncopyable
+          BOOST_ASSERT(false);
+      }
+
       shared_ptr<impl_class>
         _pimpl;
     };
@@ -802,6 +822,16 @@ namespace boost
             shared_pimpl(_weak_pimpl.lock());
           return (*shared_pimpl)(BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(BOOST_SIGNALS2_NUM_ARGS));
         }
+        bool contains(const BOOST_SIGNALS2_SIGNAL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
+          <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> &signal) const
+        {
+          return _weak_pimpl.lock().get() == signal._pimpl.get(); 
+        }
+        template <typename T>
+        bool contains(const T&) const
+        {
+          return false;
+        }
       private:
         boost::weak_ptr<detail::BOOST_SIGNALS2_SIGNAL_IMPL_CLASS_NAME(BOOST_SIGNALS2_NUM_ARGS)
           <BOOST_SIGNALS2_SIGNAL_TEMPLATE_INSTANTIATION> > _weak_pimpl;