mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 06:35:12 +00:00
Demonstrate that this is not a bug
This commit is contained in:
parent
c019ea4516
commit
3602e5eb52
@ -306,13 +306,13 @@ TEST_CASE("Reload module from file") {
|
|||||||
|
|
||||||
class TestObject {
|
class TestObject {
|
||||||
public:
|
public:
|
||||||
TestObject(std::function<void()> f) : _id(++_count), _f(f) {}
|
TestObject(std::function<void()> f) : _id(++_count), _f(std::move(f)) {}
|
||||||
|
|
||||||
~TestObject() {
|
~TestObject() {
|
||||||
py::print("~TestObject(" + std::to_string(_id) + ")");
|
|
||||||
--_count;
|
--_count;
|
||||||
|
py::print("~TestObject(" + std::to_string(_id) + ")");
|
||||||
}
|
}
|
||||||
int GetCount() { return _id; }
|
int GetCount() const { return _id; }
|
||||||
|
|
||||||
static int _count;
|
static int _count;
|
||||||
int _id;
|
int _id;
|
||||||
@ -337,6 +337,7 @@ from test_memory_leak import TestObject
|
|||||||
guard = TestObject(lambda: None)
|
guard = TestObject(lambda: None)
|
||||||
)", local, local);
|
)", local, local);
|
||||||
REQUIRE(1 == TestObject::_count);
|
REQUIRE(1 == TestObject::_count);
|
||||||
|
local.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
py::finalize_interpreter();
|
py::finalize_interpreter();
|
||||||
|
Loading…
Reference in New Issue
Block a user