From ebf36c3beca115e0e5aacca85baa11ed46c57ea5 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 30 Jun 2009 12:41:02 +0000 Subject: [PATCH] ImageFunctionsView::FunctionsTableModel: * Fixed typo in SetImageDebugInfo() setting the wrong source file function start indices. * Fixed incorrect return values in _CompareSourceFileNames(). * Fixed several instances of ignoring the source file's function start index. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31323 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../gui/team_window/ImageFunctionsView.cpp | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/apps/debugger/gui/team_window/ImageFunctionsView.cpp b/src/apps/debugger/gui/team_window/ImageFunctionsView.cpp index 9d670324ec..97f79b21ad 100644 --- a/src/apps/debugger/gui/team_window/ImageFunctionsView.cpp +++ b/src/apps/debugger/gui/team_window/ImageFunctionsView.cpp @@ -95,7 +95,7 @@ public: for (int32 i = 1; i < functionCount; i++) { if (_CompareSourceFileNames(functions[i - 1]->SourceFileName(), functions[i]->SourceFileName()) != 0) { - fSourceFileIndices[sourceFileIndex++] = 1; + fSourceFileIndices[sourceFileIndex++] = i; } } @@ -123,14 +123,7 @@ public: if (parent >= fSourceFileIndices && parent < fSourceFileIndices + fSourceFileCount) { int32 sourceIndex = (int32*)parent - fSourceFileIndices; - int32 count; - if (sourceIndex + 1 < fSourceFileCount) { - count = fSourceFileIndices[sourceIndex + 1] - - fSourceFileIndices[sourceIndex]; - } else - count = fFunctionCount - fSourceFileIndices[sourceIndex]; - - return count; + return _CountSourceFileFunctions(sourceIndex); } return 0; @@ -146,14 +139,10 @@ public: if (parent >= fSourceFileIndices && parent < fSourceFileIndices + fSourceFileCount) { int32 sourceIndex = (int32*)parent - fSourceFileIndices; - int32 count; - if (sourceIndex + 1 < fSourceFileCount) { - count = fSourceFileIndices[sourceIndex + 1] - - fSourceFileIndices[sourceIndex]; - } else - count = fFunctionCount - fSourceFileIndices[sourceIndex]; - - return index >= 0 && index < count ? fFunctions[index] : NULL; + int32 count = _CountSourceFileFunctions(sourceIndex); + int32 firstFunctionIndex = fSourceFileIndices[sourceIndex]; + return index >= 0 && index < count + ? fFunctions[firstFunctionIndex + index] : NULL; } return NULL; @@ -199,7 +188,7 @@ public: _path.Clear(); return _path.AddComponent(sourceIndex) - && _path.AddComponent(index); + && _path.AddComponent(index - fSourceFileIndices[sourceIndex]); } bool GetObjectForPath(const TreeTablePath& path, const char*& _sourceFile, @@ -220,8 +209,8 @@ public: if (componentCount == 2) { int32 index = path.ComponentAt(1); - if (index >= 0 && index < fFunctionCount) - _function = fFunctions[index]; + if (index >= 0 && index < _CountSourceFileFunctions(sourceIndex)) + _function = fFunctions[fSourceFileIndices[sourceIndex] + index]; } return true; @@ -233,15 +222,25 @@ public: } private: + int32 _CountSourceFileFunctions(int32 sourceIndex) const + { + if (sourceIndex < 0 || sourceIndex >= fSourceFileCount) + return 0; + + int32 nextFunctionIndex = sourceIndex + 1 < fSourceFileCount + ? fSourceFileIndices[sourceIndex + 1] : fFunctionCount; + return nextFunctionIndex - fSourceFileIndices[sourceIndex]; + } + static int _CompareSourceFileNames(const char* a, const char* b) { if (a == b) return 0; if (a == NULL) - return false; + return 1; if (b == NULL) - return true; + return -1; return strcmp(a, b); }