From c90d3c9d9fc6aeb31c3cbca1780f4b68234e29cd Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Sat, 5 Sep 2015 17:21:49 +0900 Subject: [PATCH] Revert 64-bit fixes for input_server. This patch reverts http://cgit.haiku-os.org/haiku/diff/?id=57ab0395ad31761e27ef6d5aa3af68cc3e4d71b2 It may fix #661. Thanks to kcg369 for pointing it out. Signed-off-by: Adrien Destugues The initial issue was the storage of a pointer in an int32 for input method cookies. This was fixed in two ways: - The int32 was initally replaced with a void*, which allowed to store a complete pointer, but changed the format of the BMessages used for communication, breaking Canna. - Then, the code was changed to not use a pointer and instead use an int32 for the cookie (see #8831). However, the int32 was still cast into a void* when putting it into a BMessage, so the problem was still there for Canna. This commit reverts the remaining parts of the initial solution and restores the ABI to use int32 everywhere. Fixes #661. --- src/servers/input/MethodMenuItem.cpp | 4 +-- src/servers/input/MethodMenuItem.h | 8 ++--- src/servers/input/MethodReplicant.cpp | 42 +++++++++++++-------------- src/servers/input/MethodReplicant.h | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/servers/input/MethodMenuItem.cpp b/src/servers/input/MethodMenuItem.cpp index 5df7b75f8a..67f0ab9189 100644 --- a/src/servers/input/MethodMenuItem.cpp +++ b/src/servers/input/MethodMenuItem.cpp @@ -17,7 +17,7 @@ #include #include "MethodMenuItem.h" -MethodMenuItem::MethodMenuItem(void* cookie, const char* name, const uchar* icon, BMenu* subMenu, BMessenger& messenger) +MethodMenuItem::MethodMenuItem(int32 cookie, const char* name, const uchar* icon, BMenu* subMenu, BMessenger& messenger) : BMenuItem(subMenu), fIcon(BRect(0, 0, MENUITEM_ICON_SIZE - 1, MENUITEM_ICON_SIZE - 1), B_CMAP8), fCookie(cookie) @@ -28,7 +28,7 @@ MethodMenuItem::MethodMenuItem(void* cookie, const char* name, const uchar* icon } -MethodMenuItem::MethodMenuItem(void* cookie, const char* name, const uchar* icon) +MethodMenuItem::MethodMenuItem(int32 cookie, const char* name, const uchar* icon) : BMenuItem(name, NULL), fIcon(BRect(0, 0, MENUITEM_ICON_SIZE - 1, MENUITEM_ICON_SIZE - 1), B_CMAP8), fCookie(cookie) diff --git a/src/servers/input/MethodMenuItem.h b/src/servers/input/MethodMenuItem.h index 25aa5c90dd..f2608dbdc3 100644 --- a/src/servers/input/MethodMenuItem.h +++ b/src/servers/input/MethodMenuItem.h @@ -24,8 +24,8 @@ class MethodMenuItem : public BMenuItem { public: - MethodMenuItem(void *cookie, const char *label, const uchar *icon, BMenu *subMenu, BMessenger &messenger); - MethodMenuItem(void *cookie, const char *label, const uchar *icon); + MethodMenuItem(int32 cookie, const char *label, const uchar *icon, BMenu *subMenu, BMessenger &messenger); + MethodMenuItem(int32 cookie, const char *label, const uchar *icon); virtual ~MethodMenuItem(); @@ -38,10 +38,10 @@ class MethodMenuItem : public BMenuItem { void SetIcon(const uchar *icon); const uchar *Icon() { return(uchar *)fIcon.Bits(); }; - void *Cookie() { return fCookie; }; + int32 Cookie() { return fCookie; }; private: BBitmap fIcon; - void *fCookie; + int32 fCookie; BMessenger fMessenger; }; diff --git a/src/servers/input/MethodReplicant.cpp b/src/servers/input/MethodReplicant.cpp index 601b57aa2c..d55b85495e 100644 --- a/src/servers/input/MethodReplicant.cpp +++ b/src/servers/input/MethodReplicant.cpp @@ -198,7 +198,7 @@ MethodReplicant::MouseDown(BPoint point) if (dynamic_cast(item) != NULL) { BMessage msg(IS_SET_METHOD); - msg.AddPointer("cookie", ((MethodMenuItem*)item)->Cookie()); + msg.AddInt32("cookie", ((MethodMenuItem*)item)->Cookie()); BMessenger messenger(fSignature); messenger.SendMessage(&msg); } @@ -216,15 +216,15 @@ void MethodReplicant::UpdateMethod(BMessage* message) { CALLED(); - void* cookie; - if (message->FindPointer("cookie", &cookie) != B_OK) { + int32 cookie; + if (message->FindInt32("cookie", &cookie) != B_OK) { fprintf(stderr, "can't find cookie in message\n"); return; } MethodMenuItem* item = FindItemByCookie(cookie); if (item == NULL) { - fprintf(stderr, "can't find item with cookie %p\n", cookie); + fprintf(stderr, "can't find item with cookie %" B_PRIx32 "\n", cookie); return; } item->SetMarked(true); @@ -239,8 +239,8 @@ void MethodReplicant::UpdateMethodIcon(BMessage* message) { CALLED(); - void* cookie; - if (message->FindPointer("cookie", &cookie) != B_OK) { + int32 cookie; + if (message->FindInt32("cookie", &cookie) != B_OK) { fprintf(stderr, "can't find cookie in message\n"); return; } @@ -255,7 +255,7 @@ MethodReplicant::UpdateMethodIcon(BMessage* message) MethodMenuItem* item = FindItemByCookie(cookie); if (item == NULL) { - fprintf(stderr, "can't find item with cookie %p\n", cookie); + fprintf(stderr, "can't find item with cookie %" B_PRIx32 "\n", cookie); return; } @@ -267,8 +267,8 @@ void MethodReplicant::UpdateMethodMenu(BMessage* message) { CALLED(); - void* cookie; - if (message->FindPointer("cookie", &cookie) != B_OK) { + int32 cookie; + if (message->FindInt32("cookie", &cookie) != B_OK) { fprintf(stderr, "can't find cookie in message\n"); return; } @@ -294,7 +294,7 @@ MethodReplicant::UpdateMethodMenu(BMessage* message) MethodMenuItem* item = FindItemByCookie(cookie); if (item == NULL) { - fprintf(stderr, "can't find item with cookie %p\n", cookie); + fprintf(stderr, "can't find item with cookie %" B_PRIx32 "\n", cookie); return; } int32 index = fMenu.IndexOf(item); @@ -317,8 +317,8 @@ void MethodReplicant::UpdateMethodName(BMessage* message) { CALLED(); - void* cookie; - if (message->FindPointer("cookie", &cookie) != B_OK) { + int32 cookie; + if (message->FindInt32("cookie", &cookie) != B_OK) { fprintf(stderr, "can't find cookie in message\n"); return; } @@ -331,7 +331,7 @@ MethodReplicant::UpdateMethodName(BMessage* message) MethodMenuItem* item = FindItemByCookie(cookie); if (item == NULL) { - fprintf(stderr, "can't find item with cookie %p\n", cookie); + fprintf(stderr, "can't find item with cookie %" B_PRIx32 "\n", cookie); return; } @@ -340,11 +340,11 @@ MethodReplicant::UpdateMethodName(BMessage* message) MethodMenuItem* -MethodReplicant::FindItemByCookie(void* cookie) +MethodReplicant::FindItemByCookie(int32 cookie) { for (int32 i = 0; i < fMenu.CountItems(); i++) { MethodMenuItem* item = (MethodMenuItem*)fMenu.ItemAt(i); - PRINT(("cookie : %p\n", item->Cookie())); + PRINT(("cookie : 0x%" B_PRIx32 "\n", item->Cookie())); if (item->Cookie() == cookie) return item; } @@ -357,8 +357,8 @@ void MethodReplicant::AddMethod(BMessage* message) { CALLED(); - void* cookie; - if (message->FindPointer("cookie", &cookie) != B_OK) { + int32 cookie; + if (message->FindInt32("cookie", &cookie) != B_OK) { fprintf(stderr, "can't find cookie in message\n"); return; } @@ -379,7 +379,7 @@ MethodReplicant::AddMethod(BMessage* message) MethodMenuItem* item = FindItemByCookie(cookie); if (item != NULL) { - fprintf(stderr, "item with cookie %p already exists\n", cookie); + fprintf(stderr, "item with cookie %" B_PRIx32 " already exists\n", cookie); return; } @@ -396,15 +396,15 @@ void MethodReplicant::RemoveMethod(BMessage* message) { CALLED(); - void* cookie; - if (message->FindPointer("cookie", &cookie) != B_OK) { + int32 cookie; + if (message->FindInt32("cookie", &cookie) != B_OK) { fprintf(stderr, "can't find cookie in message\n"); return; } MethodMenuItem* item = FindItemByCookie(cookie); if (item == NULL) { - fprintf(stderr, "can't find item with cookie %p\n", cookie); + fprintf(stderr, "can't find item with cookie %" B_PRIx32 "\n", cookie); return; } fMenu.RemoveItem(item); diff --git a/src/servers/input/MethodReplicant.h b/src/servers/input/MethodReplicant.h index d40c704b98..b826fba17c 100644 --- a/src/servers/input/MethodReplicant.h +++ b/src/servers/input/MethodReplicant.h @@ -57,7 +57,7 @@ class MethodReplicant : public BView { void UpdateMethodName(BMessage *); void AddMethod(BMessage *message); void RemoveMethod(BMessage *message); - MethodMenuItem *FindItemByCookie(void *cookie); + MethodMenuItem *FindItemByCookie(int32 cookie); }; #endif