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/app/Invoker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ If message is ``None`` the default message is sent instead.
:type message: BMessage
:return: ``B_OK`` if the message was sent, ``B_BAD_VALUE`` for no default message, and no message argument, other error forwarded from BMessenger::SendMessage().
:rtype: int
)doc", py::arg("message")=NULL)
)doc", py::arg("message")=py::none())
.def("InvokeNotify", &BInvoker::InvokeNotify, R"doc(
Send the message to its target, using the notification code specified by kind.
If message is ``None``, no message is sent to the target, but any watchers of the
Expand Down
2 changes: 1 addition & 1 deletion bindings/interface/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ py::class_<BButton,PyBButton,BControl,BView,std::unique_ptr<BButton, py::nodelet
.def("SetValue", &BButton::SetValue, "", py::arg("value"))
.def("GetPreferredSize", &BButton::GetPreferredSize, "", py::arg("_width"), py::arg("_height"))
.def("ResizeToPreferred", &BButton::ResizeToPreferred, "")
.def("Invoke", &BButton::Invoke, "", py::arg("message")=NULL)
.def("Invoke", &BButton::Invoke, "", py::arg("message")=py::none())
.def("FrameMoved", &BButton::FrameMoved, "", py::arg("newPosition"))
.def("FrameResized", &BButton::FrameResized, "", py::arg("newWidth"), py::arg("newHeight"))
.def("MakeFocus", &BButton::MakeFocus, "", py::arg("focus")=true)
Expand Down
90 changes: 90 additions & 0 deletions tests/invokeMessageDefault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import faulthandler
import gc

faulthandler.enable()

try:
import resource
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
except Exception:
pass

from Be import (
BApplication,
BButton,
BInvoker,
BMessage,
)


SENTINEL = 23117


class SafeButton(BButton):
def __init__(self):
super().__init__(
"safe default-argument button",
BMessage(0x71646274),
)
self.received = "not-called"

def Invoke(self, message=None):
self.received = message
return SENTINEL


class SafeInvoker(BInvoker):
def __init__(self):
super().__init__()
self.received = "not-called"

def Invoke(self, message=None):
self.received = message
return SENTINEL


application = BApplication(
"application/x-vnd.haiku-pyapi-invoke-default-test"
)

button = SafeButton()

button_result = BButton.Invoke(button)

if button_result != SENTINEL:
raise RuntimeError(
f"BButton trampoline returned {button_result!r}"
)

if button.received is not None:
raise RuntimeError(
f"BButton received {button.received!r}"
)

print("BBUTTON INVOKE DEFAULT REGRESSION: PASS")


invoker = SafeInvoker()

invoker_result = BInvoker.Invoke(invoker)

if invoker_result != SENTINEL:
raise RuntimeError(
f"BInvoker trampoline returned {invoker_result!r}"
)

if invoker.received is not None:
raise RuntimeError(
f"BInvoker received {invoker.received!r}"
)

print("BINVOKER INVOKE DEFAULT REGRESSION: PASS")


del invoker
del button
del application

gc.collect()

print("INVOKE MESSAGE DEFAULT REGRESSION TEST: PASS")