From 944bc060606c23abbf723d83ca3995be0c3336a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 24 Oct 2008 21:28:21 +0000 Subject: [PATCH] * The way subdirectories for the input_server add-ons were defined was a bit weird. * Set fHandler to NULL in _UnregisterAddOns(), just in case it is called twice (which it probably never is... but be defensive). * If a B_NODE_MONITOR message does not contain all the necessary fields, drop into the debugger when compiling in DEBUG mode. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28317 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/input/AddOnManager.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/servers/input/AddOnManager.cpp b/src/servers/input/AddOnManager.cpp index 0888128730..ca45f7a800 100644 --- a/src/servers/input/AddOnManager.cpp +++ b/src/servers/input/AddOnManager.cpp @@ -146,6 +146,9 @@ AddOnManager::SaveState() } +// #pragma mark - + + void AddOnManager::_RegisterAddOns() { @@ -168,11 +171,12 @@ AddOnManager::_RegisterAddOns() B_COMMON_ADDONS_DIRECTORY, B_BEOS_ADDONS_DIRECTORY }; - const char subDirectories[][24] = { + const char* subDirectories[] = { "input_server/devices", "input_server/filters", "input_server/methods" }; + int32 subDirectoryCount = sizeof(subDirectories) / sizeof(const char*); node_ref nref; BDirectory directory; @@ -180,7 +184,7 @@ AddOnManager::_RegisterAddOns() // when safemode, only B_BEOS_ADDONS_DIRECTORY is used for (uint32 i = fSafeMode ? 2 : 0; i < sizeof(directories) / sizeof(directory_which); i++) { - for (uint32 j = 0; j < sizeof(subDirectories) / sizeof(char[24]); j++) { + for (uint32 j = 0; j < subDirectoryCount; j++) { if (find_directory(directories[i], &path) == B_OK && path.Append(subDirectories[j]) == B_OK && directory.SetTo(path.Path()) == B_OK @@ -202,6 +206,7 @@ AddOnManager::_UnregisterAddOns() int32 exitValue; wait_for_thread(fAddOnMonitor->Thread(), &exitValue); delete fHandler; + fHandler = NULL; // We have to stop manually the add-ons because the monitor doesn't // disable them on exit @@ -500,6 +505,9 @@ AddOnManager::_RegisterMethod(BInputServerMethod* method, const entry_ref& ref, } +// #pragma mark - + + void AddOnManager::_UnloadReplicant() { @@ -830,8 +838,17 @@ AddOnManager::_HandleDeviceMonitor(BMessage* message) const char* path; const char* watchedPath; if (message->FindString("watched_path", &watchedPath) != B_OK - || message->FindString("path", &path) != B_OK) + || message->FindString("path", &path) != B_OK) { +#if DEBUG + char string[1024]; + sprintf(string, "message does not contain all fields - " + "watched_path: %d, path: %d\n", + message->HasString("watched_path"), + message->HasString("path")); + debugger(string); +#endif return; + } // Notify all watching devices