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
4 changes: 2 additions & 2 deletions bindings/interface/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class PyBView : public BView{
PYBIND11_OVERLOAD(void, BView, AllAttached);
}
void DetachedFromWindow() override {
PYBIND11_OVERLOAD(void, BView, AllAttached);
PYBIND11_OVERLOAD(void, BView, DetachedFromWindow);
}
void AllDetached() override {
PYBIND11_OVERLOAD(void, BView, AllAttached);
PYBIND11_OVERLOAD(void, BView, AllDetached);
}
void MessageReceived(BMessage* message) override {
PYBIND11_OVERLOAD(void, BView, MessageReceived, message);
Expand Down
53 changes: 53 additions & 0 deletions tests/viewDetachCallbacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from Be import BApplication, BView


EXPECTED_CALLBACKS = [
"DetachedFromWindow",
"AllDetached",
]


class CallbackProbe(BView):
def __init__(self):
BView.__init__(
self,
"callback-probe",
0,
None,
)
self.calls = []

def AllAttached(self):
self.calls.append("AllAttached")

def DetachedFromWindow(self):
self.calls.append("DetachedFromWindow")

def AllDetached(self):
self.calls.append("AllDetached")


def main():
application = BApplication(
"application/x-vnd.haiku-pyapi-view-detach-callback-test"
)
view = CallbackProbe()

BView.DetachedFromWindow(view)
BView.AllDetached(view)

if view.calls != EXPECTED_CALLBACKS:
raise SystemExit(
"FAIL: incorrect detach callback dispatch: "
f"{view.calls!r}"
)

print("callbacks =", view.calls)
print("VIEW DETACH CALLBACK REGRESSION TEST: PASS")

# Keep the BApplication alive until the probe has completed.
del application


if __name__ == "__main__":
main()