Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/interface/Control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ m.attr("B_CONTROL_PARTIALLY_ON") = 2;

//m.attr("BIcon") = BIcon;

py::class_<BControl, PyBControl, BView, BInvoker>(m, "BControl")
py::class_<BControl, PyBControl, BView, BInvoker, std::unique_ptr<BControl, py::nodelete>>(m, "BControl")
.def(py::init<BRect, const char *, const char *, BMessage *, unsigned int, unsigned int>(), "", py::arg("frame"), py::arg("name"), py::arg("label"), py::arg("message"), py::arg("resizingMode"), py::arg("flags"))
.def(py::init<const char *, const char *, BMessage *, unsigned int>(), "", py::arg("name"), py::arg("label"), py::arg("message"), py::arg("flags"))
.def(py::init<BMessage *>(), "", py::arg("data"))
Expand Down
43 changes: 43 additions & 0 deletions tests/controlHolderOwnership.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import gc

from Be import (
BApplication,
BControl,
BRect,
BWindow,
B_NOT_RESIZABLE,
window_type,
)


application = BApplication(
"application/x-vnd.haiku-pyapi-bcontrol-holder-test"
)

window = BWindow(
BRect(100.0, 100.0, 320.0, 220.0),
"BControl holder test",
window_type.B_TITLED_WINDOW,
B_NOT_RESIZABLE,
)

control = BControl(
BRect(10.0, 10.0, 180.0, 40.0),
"holder-probe",
"probe",
None,
0,
0,
)

window.AddChild(control, None)
window.Quit()

del control
gc.collect()

del window
del application
gc.collect()

print("BCONTROL HOLDER OWNERSHIP REGRESSION TEST: PASS")