fix some more bugs in scripting handling, this seems to never end

Having canna input method installed shouldn't crash Haiku anymore


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17810 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-06-12 23:45:55 +00:00
parent 4b25c48853
commit da08acb8bf
3 changed files with 236 additions and 280 deletions

View File

@ -53,7 +53,7 @@ static property_info sShelfPropertyList[] = {
"... of Replicant {index | name | id} of ...", 0,
},
{}
{ 0, { 0 }, { 0 }, 0, 0 }
};
static property_info sReplicantPropertyList[] = {
@ -90,7 +90,9 @@ static property_info sReplicantPropertyList[] = {
{ },
{ B_DIRECT_SPECIFIER },
NULL, 0,
}
},
{ 0, { 0 }, { 0 }, 0, 0 }
};

View File

@ -3499,11 +3499,10 @@ BView::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
return this;
BPropertyInfo propertyInfo(sViewPropInfo);
status_t err = B_BAD_SCRIPT_SYNTAX;
BMessage replyMsg(B_REPLY);
switch (propertyInfo.FindMatch(msg, index, specifier, what, property)) {
case B_ERROR:
break;
case 0:
case 1:
case 2:
@ -3515,87 +3514,75 @@ BView::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
if (fShelf) {
msg->PopSpecifier();
return fShelf;
} else {
BMessage replyMsg(B_MESSAGE_NOT_UNDERSTOOD);
replyMsg.AddInt32("error", B_NAME_NOT_FOUND);
replyMsg.AddString("message", "This window doesn't have a shelf");
msg->SendReply(&replyMsg);
return NULL;
}
err = B_NAME_NOT_FOUND;
replyMsg.AddString("message", "This window doesn't have a shelf");
break;
case 6:
case 7:
case 8:
{
if (fFirstChild) {
BView *child;
switch (msg->what) {
case B_INDEX_SPECIFIER:
{
case 6: {
if (!fFirstChild) {
err = B_NAME_NOT_FOUND;
replyMsg.AddString("message", "This window doesn't have children.");
break;
}
BView *child = NULL;
switch (what) {
case B_INDEX_SPECIFIER: {
int32 index;
msg->FindInt32("data", &index);
err = specifier->FindInt32("index", &index);
if (err == B_OK)
child = ChildAt(index);
break;
}
case B_REVERSE_INDEX_SPECIFIER:
{
case B_REVERSE_INDEX_SPECIFIER: {
int32 rindex;
msg->FindInt32("data", &rindex);
err = specifier->FindInt32("index", &rindex);
if (err == B_OK)
child = ChildAt(CountChildren() - rindex);
break;
}
case B_NAME_SPECIFIER:
{
case B_NAME_SPECIFIER: {
const char *name;
msg->FindString("data", &name);
err = specifier->FindString("name", &name);
if (err == B_OK)
child = FindView(name);
break;
}
default:
child = NULL;
break;
}
if (child != NULL) {
msg->PopSpecifier();
return child;
} else {
BMessage replyMsg(B_MESSAGE_NOT_UNDERSTOOD);
replyMsg.AddInt32("error", B_BAD_INDEX);
}
if (err == B_OK)
err = B_BAD_INDEX;
replyMsg.AddString("message", "Cannot find view at/with specified index/name.");
msg->SendReply(&replyMsg);
return NULL;
}
} else {
BMessage replyMsg(B_MESSAGE_NOT_UNDERSTOOD);
replyMsg.AddInt32("error", B_NAME_NOT_FOUND);
replyMsg.AddString("message", "This window doesn't have children.");
msg->SendReply(&replyMsg);
return NULL;
}
break;
}
default:
break;
return BHandler::ResolveSpecifier(msg, index, specifier, what, property);
}
return BHandler::ResolveSpecifier(msg, index, specifier, what, property);
if (err == B_BAD_SCRIPT_SYNTAX) {
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);
msg->SendReply(&replyMsg);
return NULL;
}
void
BView::MessageReceived(BMessage *msg)
{
BMessage specifier;
int32 what;
const char *prop;
int32 index;
status_t err;
if (!msg->HasSpecifiers()) {
switch (msg->what) {
case B_VIEW_RESIZED:
@ -3652,90 +3639,66 @@ BView::MessageReceived(BMessage *msg)
}
default:
BHandler::MessageReceived(msg);
break;
return BHandler::MessageReceived(msg);
}
return;
}
err = msg->GetCurrentSpecifier(&index, &specifier, &what, &prop);
if (err == B_OK) {
BMessage replyMsg;
BMessage replyMsg(B_REPLY);
status_t err = B_BAD_SCRIPT_SYNTAX;
int32 index;
BMessage specifier;
int32 what;
const char *prop;
switch (msg->what) {
case B_GET_PROPERTY:
{
replyMsg.what = B_NO_ERROR;
replyMsg.AddInt32("error", B_OK);
if (msg->GetCurrentSpecifier(&index, &specifier, &what, &prop) != B_OK)
return BHandler::MessageReceived(msg);
if (strcmp(prop, "Frame") == 0)
replyMsg.AddRect("result", Frame());
else if (strcmp(prop, "Hidden") == 0)
replyMsg.AddBool( "result", IsHidden());
BPropertyInfo propertyInfo(sViewPropInfo);
switch (propertyInfo.FindMatch(msg, index, &specifier, what, prop)) {
case 0:
err = replyMsg.AddRect("result", Frame());
break;
}
case B_SET_PROPERTY:
{
if (strcmp(prop, "Frame") == 0) {
case 1: {
BRect newFrame;
if (msg->FindRect("data", &newFrame) == B_OK) {
err = msg->FindRect("data", &newFrame);
if (err == B_OK) {
MoveTo(newFrame.LeftTop());
ResizeTo(newFrame.right, newFrame.bottom);
replyMsg.what = B_NO_ERROR;
replyMsg.AddInt32("error", B_OK);
} else {
replyMsg.what = B_MESSAGE_NOT_UNDERSTOOD;
replyMsg.AddInt32("error", B_BAD_SCRIPT_SYNTAX);
replyMsg.AddString("message", "Didn't understand the specifier(s)");
}
} else if (strcmp(prop, "Hidden") == 0) {
break;
}
case 2:
err = replyMsg.AddBool( "result", IsHidden());
break;
case 3: {
bool newHiddenState;
if (msg->FindBool("data", &newHiddenState) == B_OK) {
if (!IsHidden() && newHiddenState == true) {
err = msg->FindBool("data", &newHiddenState);
if (err == B_OK) {
if (!IsHidden() && newHiddenState == true)
Hide();
replyMsg.what = B_NO_ERROR;
replyMsg.AddInt32( "error", B_OK);
}
else if (IsHidden() && newHiddenState == false) {
else if (IsHidden() && newHiddenState == false)
Show();
replyMsg.what = B_NO_ERROR;
replyMsg.AddInt32("error", B_OK);
} else {
replyMsg.what = B_MESSAGE_NOT_UNDERSTOOD;
replyMsg.AddInt32("error", B_BAD_SCRIPT_SYNTAX);
replyMsg.AddString("message", "Didn't understand the specifier(s)");
}
} else {
replyMsg.what = B_MESSAGE_NOT_UNDERSTOOD;
replyMsg.AddInt32("error", B_BAD_SCRIPT_SYNTAX);
replyMsg.AddString("message", "Didn't understand the specifier(s)");
}
}
case 5:
err = replyMsg.AddInt32("result", CountChildren());
break;
default:
return BHandler::MessageReceived(msg);
}
case B_COUNT_PROPERTIES:
if (strcmp(prop, "View") == 0) {
replyMsg.what = B_NO_ERROR;
replyMsg.AddInt32("error", B_OK);
replyMsg.AddInt32("result", CountChildren());
}
break;
}
msg->SendReply(&replyMsg);
} else {
BMessage replyMsg(B_MESSAGE_NOT_UNDERSTOOD);
replyMsg.AddInt32("error" , B_BAD_SCRIPT_SYNTAX);
if (err == B_BAD_SCRIPT_SYNTAX) {
replyMsg.what = B_MESSAGE_NOT_UNDERSTOOD;
replyMsg.AddString("message", "Didn't understand the specifier(s)");
msg->SendReply(&replyMsg);
} else if (err < B_OK) {
replyMsg.what = B_ERROR;
replyMsg.AddString("message", strerror(err));
}
replyMsg.AddInt32("error", err);
msg->SendReply(&replyMsg);
}

View File

@ -661,14 +661,7 @@ BWindow::MessageReceived(BMessage *msg)
BMessage replyMsg(B_REPLY);
bool handled = false;
switch (msg->what) {
case B_GET_PROPERTY:
case B_SET_PROPERTY:
case B_CREATE_PROPERTY:
case B_DELETE_PROPERTY:
case B_COUNT_PROPERTIES:
case B_EXECUTE_PROPERTY:
case B_GET_SUPPORTED_SUITES: {
BMessage specifier;
int32 what;
const char *prop;
@ -795,8 +788,6 @@ BWindow::MessageReceived(BMessage *msg)
default:
return BLooper::MessageReceived(msg);
}
}
}
if (handled) {
if (msg->what == B_SET_PROPERTY)