Ejemplo n.º 1
0
void
TeamWindow::_HandleSourceCodeChanged()
{
	// If we don't have an active function anymore, the message is obsolete.
	if (fActiveFunction == NULL)
		return;

	// get a reference to the source code
	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();

	_SetActiveSourceCode(sourceCode);
}