Qt5 new signal to lambda connections memory leak

前端 未结 1 796
耶瑟儿~
耶瑟儿~ 2021-01-03 20:39

The new Qt5 signals and slots syntax allows us to connect signals not only to slots, but also to plain old functions and functors/lambdas. Now the problem is, that lambdas a

相关标签:
1条回答
  • 2021-01-03 20:49

    The example is over-engineered (why using a QSharedPointer? why capturing it by value?). But indeed Qt is leaking the functor object.

    The point is that the internal connection list is simply marked as dirty, and not cleared until either the sender is deleted or a new signal is connected (see the usages of cleanConnectionLists).

    I pushed a couple of patches that should fix this behaviour: https://codereview.qt-project.org/#change,42976 and 42979

    0 讨论(0)
提交回复
热议问题