From 21d806359150aa1b069e9e2d6051da2ac92431ff Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 21 Jun 2013 18:50:47 -0400 Subject: [PATCH] Slight tweak to located file handling. - When the user helps locate a missing source file, verify that the source and located file names match. If they don't, prompt the user to verify that they did in fact intend to choose the file in question. Helps avoid accidentally clicking the wrong file when performing location. --- .../gui/team_window/TeamWindow.cpp | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 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 563f0611c2..2b64bbea73 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -349,7 +349,9 @@ TeamWindow::MessageReceived(BMessage* message) case B_REFS_RECEIVED: { entry_ref locatedPath; - message->FindRef("refs", &locatedPath); + if (message->FindRef("refs", &locatedPath) != B_OK) + break; + _HandleResolveMissingSourceFile(locatedPath); break; } @@ -1438,11 +1440,30 @@ TeamWindow::_HandleResolveMissingSourceFile(entry_ref& locatedPath) ->SourceFile(); if (sourceFile != NULL) { BString sourcePath; - BString targetPath; sourceFile->GetPath(sourcePath); - BPath path(&locatedPath); - targetPath = path.Path(); - fListener->SourceEntryLocateRequested(sourcePath, targetPath); + BPath sourceFilePath(sourcePath); + BPath targetFilePath(&locatedPath); + if (sourceFilePath.InitCheck() != B_OK + || targetFilePath.InitCheck() != B_OK) { + return; + } + + if (strcmp(sourceFilePath.Leaf(), targetFilePath.Leaf()) != 0) { + BString message; + message.SetToFormat("The names of source file '%s' and located" + " file '%s' differ. Use file anyway?", + sourceFilePath.Leaf(), targetFilePath.Leaf()); + BAlert* alert = new(std::nothrow) BAlert( + "Source path mismatch", message.String(), "Cancel", "Use"); + if (alert == NULL) + return; + + int32 choice = alert->Go(); + if (choice <= 0) + return; + } + fListener->SourceEntryLocateRequested(sourcePath, + targetFilePath.Path()); fListener->FunctionSourceCodeRequested(fActiveFunction); } }