From 78aa8eea3db5e6af2e525ae29e3afc2248517586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 11 Aug 2006 20:01:26 +0000 Subject: [PATCH] * Added get_uint32_color() again, the previous "hack" doesn't compile on GCC 4. * Fixed buggy scripting error responses: "error" is only included on error, and B_ERROR (-1) can hardly be a candidate for the BMessage::what field (uint32). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18490 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 53 +++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 64321dab11..b0599057f0 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -90,6 +90,16 @@ static property_info sViewPropInfo[] = { // #pragma mark - +static inline uint32 +get_uint32_color(rgb_color color) +{ + return *(uint32 *)&color; +} + + +// #pragma mark - + + namespace BPrivate { ViewState::ViewState() @@ -451,13 +461,13 @@ BView::Archive(BMessage *data, bool deep) const // colors if (ret == B_OK) - ret = data->AddInt32("_color", (const uint32 &)HighColor()); + ret = data->AddInt32("_color", get_uint32_color(HighColor())); if (ret == B_OK) - ret = data->AddInt32("_color", (const uint32 &)LowColor()); + ret = data->AddInt32("_color", get_uint32_color(LowColor())); if (ret == B_OK) - ret = data->AddInt32("_color", (const uint32 &)ViewColor()); + ret = data->AddInt32("_color", get_uint32_color(ViewColor())); // NOTE: we do not use this flag any more // if ( 1 ){ @@ -3562,18 +3572,18 @@ BView::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, return BHandler::ResolveSpecifier(msg, index, specifier, what, property); } - if (err == B_BAD_SCRIPT_SYNTAX) { + if (err < B_OK) { replyMsg.what = B_MESSAGE_NOT_UNDERSTOOD; - replyMsg.AddString("message", "Didn't understand the specifier(s)"); - } else if (err < B_OK) { - replyMsg.what = B_ERROR; - replyMsg.AddString("message", strerror(err)); + replyMsg.AddInt32("error", err); + + if (err == B_BAD_SCRIPT_SYNTAX) + replyMsg.AddString("message", "Didn't understand the specifier(s)"); + else + replyMsg.AddString("message", strerror(err)); } - - replyMsg.AddInt32("error", err); + msg->SendReply(&replyMsg); return NULL; - } @@ -3642,16 +3652,18 @@ BView::MessageReceived(BMessage *msg) return; } + // Scripting message + BMessage replyMsg(B_REPLY); status_t err = B_BAD_SCRIPT_SYNTAX; int32 index; BMessage specifier; int32 what; const char *prop; - + if (msg->GetCurrentSpecifier(&index, &specifier, &what, &prop) != B_OK) return BHandler::MessageReceived(msg); - + BPropertyInfo propertyInfo(sViewPropInfo); switch (propertyInfo.FindMatch(msg, index, &specifier, what, prop)) { case 0: @@ -3686,15 +3698,16 @@ BView::MessageReceived(BMessage *msg) return BHandler::MessageReceived(msg); } - if (err == B_BAD_SCRIPT_SYNTAX) { + if (err < B_OK) { replyMsg.what = B_MESSAGE_NOT_UNDERSTOOD; - replyMsg.AddString("message", "Didn't understand the specifier(s)"); - } else if (err < B_OK) { - replyMsg.what = B_ERROR; - replyMsg.AddString("message", strerror(err)); + replyMsg.AddInt32("error", err); + + if (err == B_BAD_SCRIPT_SYNTAX) + replyMsg.AddString("message", "Didn't understand the specifier(s)"); + else + replyMsg.AddString("message", strerror(err)); } - - replyMsg.AddInt32("error", err); + msg->SendReply(&replyMsg); }