From f7337f78ee36ed48b433cdc9f4ef22155bfeb7d0 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 13 Nov 2011 20:13:56 -0500 Subject: [PATCH 1/2] Fixed intelligent file location services in Debugger. - When adding files/directories into the file manager, we now also take care to add them to their respective parent entry lists as well. This allows the intelligent location functions to actually traverse directories to update all sibling/parent locations properly as needed. - Slight changes to ensure that the implicit/explicit status of the location can be passed around throughout the process. Needed for the above to work. Resolves the intelligent location portion of #8095. --- src/apps/debugger/files/FileManager.cpp | 28 +++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/apps/debugger/files/FileManager.cpp b/src/apps/debugger/files/FileManager.cpp index b7b5635287..10f989cce5 100644 --- a/src/apps/debugger/files/FileManager.cpp +++ b/src/apps/debugger/files/FileManager.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -152,7 +153,7 @@ public: // parent already located -- locate the entry in the parent BString locatedDirectoryPath; if (directory->GetLocatedPath(locatedDirectoryPath)) - _LocateEntryInParentDir(file, locatedDirectoryPath); + _LocateEntryInParentDir(file, locatedDirectoryPath, true); } } @@ -200,17 +201,17 @@ private: } bool _LocateDirectory(LocatableDirectory* directory, - const BString& locatedPath) + const BString& locatedPath, bool implicit) { if (directory == NULL || directory->State() != LOCATABLE_ENTRY_UNLOCATED) { return false; } - if (!_LocateEntry(directory, locatedPath, true, true)) + if (!_LocateEntry(directory, locatedPath, implicit, true)) return false; - _LocateEntries(directory, locatedPath); + _LocateEntries(directory, locatedPath, implicit); return true; } @@ -244,14 +245,14 @@ private: BString locatedName; _SplitPath(locatedPath, locatedDirectory, locatedName); if (locatedName == entry->Name()) - _LocateDirectory(entry->Parent(), locatedDirectory); + _LocateDirectory(entry->Parent(), locatedDirectory, implicit); } return true; } bool _LocateEntryInParentDir(LocatableEntry* entry, - const BString& locatedDirectoryPath) + const BString& locatedDirectoryPath, bool implicit) { // construct the located entry path BString locatedEntryPath(locatedDirectoryPath); @@ -260,11 +261,11 @@ private: locatedEntryPath << '/'; locatedEntryPath << entry->Name(); - return _LocateEntry(entry, locatedEntryPath, true, false); + return _LocateEntry(entry, locatedEntryPath, implicit, false); } void _LocateEntries(LocatableDirectory* directory, - const BString& locatedPath) + const BString& locatedPath, bool implicit) { for (LocatableEntryList::ConstIterator it = directory->Entries().GetIterator(); @@ -272,13 +273,13 @@ private: if (entry->State() == LOCATABLE_ENTRY_LOCATED_EXPLICITLY) continue; - if (_LocateEntryInParentDir(entry, locatedPath)) { + if (_LocateEntryInParentDir(entry, locatedPath, implicit)) { // recurse for directories if (LocatableDirectory* subDir = dynamic_cast(entry)) { BString locatedEntryPath; if (subDir->GetLocatedPath(locatedEntryPath)) - _LocateEntries(subDir, locatedEntryPath); + _LocateEntries(subDir, locatedEntryPath, implicit); } } } @@ -313,6 +314,8 @@ private: directory->ReleaseReference(); return NULL; } + + directory->AddEntry(file); fEntries.Insert(file); return file; @@ -361,8 +364,11 @@ private: && parentDirectory->State() != LOCATABLE_ENTRY_UNLOCATED) { BString locatedDirectoryPath; if (parentDirectory->GetLocatedPath(locatedDirectoryPath)) - _LocateEntryInParentDir(directory, locatedDirectoryPath); + _LocateEntryInParentDir(directory, locatedDirectoryPath, true); } + + if (parentDirectory != NULL) + parentDirectory->AddEntry(directory); fEntries.Insert(directory); return directory; From 72d140460db0cd36f2eb0b540980b5d0ddab6d9b Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 13 Nov 2011 20:16:47 -0500 Subject: [PATCH 2/2] Remember the last source location path chosen by the user. - When the user chooses the location of a source file via the file panel, we now preserve the file panel so it can remember its previous location when invoked again. Resolves the other part of #8095. --- .../gui/team_window/TeamWindow.cpp | 19 ++++++++++++------- .../gui/team_window/TeamWindow.h | 4 +++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index 8ed0f3e8a2..9f00d6393a 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2010, Rene Gollent, rene@gollent.com. + * Copyright 2010-2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -107,7 +107,8 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener) fRunButton(NULL), fStepOverButton(NULL), fStepIntoButton(NULL), - fStepOutButton(NULL) + fStepOutButton(NULL), + fSourceLocatePanel(NULL) { fTeam->Lock(); BString name = fTeam->Name(); @@ -138,6 +139,8 @@ TeamWindow::~TeamWindow() _SetActiveStackTrace(NULL); _SetActiveImage(NULL); _SetActiveThread(NULL); + + delete fSourceLocatePanel; } @@ -247,13 +250,15 @@ TeamWindow::MessageReceived(BMessage* message) && fActiveFunction->GetFunctionDebugInfo() ->SourceFile() != NULL && fActiveSourceCode != NULL && fActiveSourceCode->GetSourceFile() == NULL) { - BFilePanel* panel = NULL; try { - panel = new BFilePanel(B_OPEN_PANEL, - new BMessenger(this)); - panel->Show(); + if (fSourceLocatePanel == NULL) { + fSourceLocatePanel = new BFilePanel(B_OPEN_PANEL, + new BMessenger(this)); + } + fSourceLocatePanel->Show(); } catch (...) { - delete panel; + delete fSourceLocatePanel; + fSourceLocatePanel = NULL; } } break; diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h index 4995662320..996c45b1e3 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2010, Rene Gollent, rene@gollent.com. + * Copyright 2010-2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef TEAM_WINDOW_H @@ -24,6 +24,7 @@ class BButton; +class BFilePanel; class BMenuBar; class BSplitView; class BStringView; @@ -185,6 +186,7 @@ private: BSplitView* fThreadSplitView; InspectorWindow* fInspectorWindow; GUITeamUISettings fUISettings; + BFilePanel* fSourceLocatePanel; };