Fix updating of source path.
Factor out updating of the source path view into a dedicated function, and fix some errors that would sometimes result in the text not updating properly when switching stack frames, particularly if the target frame didn't have source code available.
This commit is contained in:
parent
028ad0311c
commit
c2d1fc4ffa
@ -990,6 +990,7 @@ TeamWindow::_SetActiveSourceCode(SourceCode* sourceCode)
|
||||
|
||||
fSourceView->SetSourceCode(fActiveSourceCode);
|
||||
|
||||
_UpdateSourcePathState();
|
||||
_ScrollToActiveFunction();
|
||||
}
|
||||
|
||||
@ -1049,6 +1050,39 @@ TeamWindow::_UpdateRunButtons()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamWindow::_UpdateSourcePathState()
|
||||
{
|
||||
LocatableFile* sourceFile = NULL;
|
||||
BString sourceText = "Source file unavailable.";
|
||||
BString truncatedText;
|
||||
|
||||
if (fActiveSourceCode != NULL) {
|
||||
sourceFile = fActiveFunction->GetFunctionDebugInfo()->SourceFile();
|
||||
|
||||
if (sourceFile != NULL && !sourceFile->GetLocatedPath(sourceText))
|
||||
sourceFile->GetPath(sourceText);
|
||||
|
||||
if (fActiveSourceCode->GetSourceFile() == NULL && sourceFile != NULL) {
|
||||
sourceText.Prepend("Click to locate source file '");
|
||||
sourceText += "'";
|
||||
truncatedText = sourceText;
|
||||
fSourcePathView->TruncateString(&truncatedText, B_TRUNCATE_MIDDLE,
|
||||
fSourcePathView->Bounds().Width());
|
||||
} else if (sourceFile != NULL) {
|
||||
sourceText.Prepend("File: ");
|
||||
}
|
||||
}
|
||||
|
||||
if (!truncatedText.IsEmpty() && truncatedText != sourceText) {
|
||||
fSourcePathView->SetToolTip(sourceText.String());
|
||||
fSourcePathView->SetText(truncatedText);
|
||||
}
|
||||
else
|
||||
fSourcePathView->SetText(sourceText);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TeamWindow::_ScrollToActiveFunction()
|
||||
{
|
||||
@ -1183,34 +1217,9 @@ TeamWindow::_HandleSourceCodeChanged()
|
||||
AutoLocker< ::Team> locker(fTeam);
|
||||
|
||||
SourceCode* sourceCode = fActiveFunction->GetFunction()->GetSourceCode();
|
||||
LocatableFile* sourceFile = NULL;
|
||||
BString sourceText;
|
||||
BString truncatedText;
|
||||
if (sourceCode == NULL)
|
||||
sourceCode = fActiveFunction->GetSourceCode();
|
||||
|
||||
if (sourceCode != NULL)
|
||||
sourceFile = fActiveFunction->GetFunctionDebugInfo()->SourceFile();
|
||||
|
||||
if (sourceFile != NULL && !sourceFile->GetLocatedPath(sourceText))
|
||||
sourceFile->GetPath(sourceText);
|
||||
|
||||
if (sourceCode != NULL && sourceCode->GetSourceFile() == NULL
|
||||
&& sourceFile != NULL) {
|
||||
sourceText.Prepend("Click to locate source file '");
|
||||
sourceText += "'";
|
||||
truncatedText = sourceText;
|
||||
fSourcePathView->TruncateString(&truncatedText, B_TRUNCATE_MIDDLE,
|
||||
fSourcePathView->Bounds().Width());
|
||||
if (sourceText != truncatedText)
|
||||
fSourcePathView->SetToolTip(sourceText.String());
|
||||
fSourcePathView->SetText(truncatedText.String());
|
||||
} else if (sourceFile != NULL) {
|
||||
sourceText.Prepend("File: ");
|
||||
fSourcePathView->SetText(sourceText.String());
|
||||
} else
|
||||
fSourcePathView->SetText("Source file unavailable.");
|
||||
|
||||
BReference<SourceCode> sourceCodeReference(sourceCode);
|
||||
|
||||
locker.Unlock();
|
||||
|
@ -132,6 +132,7 @@ private:
|
||||
void _SetActiveSourceCode(SourceCode* sourceCode);
|
||||
void _UpdateCpuState();
|
||||
void _UpdateRunButtons();
|
||||
void _UpdateSourcePathState();
|
||||
void _ScrollToActiveFunction();
|
||||
|
||||
void _HandleThreadStateChanged(thread_id threadID);
|
||||
|
Loading…
x
Reference in New Issue
Block a user