381 | | if (fActiveFunction != NULL |
382 | | && fActiveFunction->GetFunctionDebugInfo() |
383 | | ->SourceFile() != NULL && fActiveSourceCode != NULL |
384 | | && fActiveSourceCode->GetSourceFile() == NULL |
385 | | && fActiveFunction->GetFunction()->SourceCodeState() |
386 | | != FUNCTION_SOURCE_NOT_LOADED) { |
387 | | try { |
388 | | if (fFilePanel == NULL) { |
389 | | fFilePanel = new BFilePanel(B_OPEN_PANEL, |
390 | | new BMessenger(this)); |
391 | | } |
392 | | fFilePanel->Show(); |
393 | | } catch (...) { |
394 | | delete fFilePanel; |
395 | | fFilePanel = NULL; |
396 | | } |
397 | | } |
398 | | break; |
| 385 | _HandleLocateSourceRequest(); |
| 1572 | void |
| 1573 | TeamWindow::_HandleLocateSourceRequest() |
| 1574 | { |
| 1575 | if (fActiveFunction == NULL) |
| 1576 | return; |
| 1577 | if (fActiveFunction->GetFunctionDebugInfo()->SourceFile() == NULL) |
| 1578 | return; |
| 1579 | if (fActiveSourceCode == NULL) |
| 1580 | return; |
| 1581 | if (fActiveSourceCode->GetSourceFile() != NULL) |
| 1582 | return; |
| 1583 | if (fActiveFunction->GetFunction()->SourceCodeState() |
| 1584 | == FUNCTION_SOURCE_NOT_LOADED) { |
| 1585 | return; |
| 1586 | } |
| 1587 | |
| 1588 | BPath path; |
| 1589 | BString data; |
| 1590 | fActiveFunction->GetFunctionDebugInfo()->SourceFile()->GetPath(data); |
| 1591 | if (path.SetTo(data) != B_OK) |
| 1592 | return; |
| 1593 | |
| 1594 | BString predicate; |
| 1595 | predicate.SetToFormat("name=%s", path.Leaf()); |
| 1596 | BQuery query; |
| 1597 | query.SetPredicate(predicate); |
| 1598 | |
| 1599 | BVolumeRoster roster; |
| 1600 | BVolume volume; |
| 1601 | |
| 1602 | BStringList entries; |
| 1603 | |
| 1604 | while (roster.GetNextVolume(&volume) == B_OK) { |
| 1605 | entry_ref ref; |
| 1606 | if (query.SetVolume(&volume) != B_OK) |
| 1607 | continue; |
| 1608 | |
| 1609 | if (query.Fetch() != B_OK) |
| 1610 | continue; |
| 1611 | |
| 1612 | while (query.GetNextRef(&ref) == B_OK) { |
| 1613 | path.SetTo(&ref); |
| 1614 | entries.Add(path.Path()); |
| 1615 | } |
| 1616 | |
| 1617 | query.Clear(); |
| 1618 | } |
| 1619 | |
| 1620 | int32 count = entries.CountStrings(); |
| 1621 | if (count > 0) { |
| 1622 | entries.Sort(); |
| 1623 | BPopUpMenu* menu = new(std::nothrow) BPopUpMenu(""); |
| 1624 | if (menu == NULL) |
| 1625 | return; |
| 1626 | BPrivate::ObjectDeleter<BPopUpMenu> menuDeleter(menu); |
| 1627 | BMenuItem* item = NULL; |
| 1628 | for (int32 i = 0; i < count; i++) { |
| 1629 | item = new(std::nothrow) BMenuItem(entries.StringAt(i).String(), |
| 1630 | NULL); |
| 1631 | if (item == NULL) |
| 1632 | return; |
| 1633 | menu->AddItem(item); |
| 1634 | } |
| 1635 | menu->AddSeparatorItem(); |
| 1636 | BMenuItem* manualItem = new(std::nothrow) BMenuItem( |
| 1637 | "Locate manually" B_UTF8_ELLIPSIS, NULL); |
| 1638 | if (manualItem == NULL) |
| 1639 | return; |
| 1640 | menu->AddItem(manualItem); |
| 1641 | |
| 1642 | BPoint point; |
| 1643 | fSourcePathView->GetMouse(&point, NULL, false); |
| 1644 | fSourcePathView->ConvertToScreen(&point); |
| 1645 | item = menu->Go(point, false, true); |
| 1646 | if (item == NULL) |
| 1647 | return; |
| 1648 | else if (item != manualItem) { |
| 1649 | entry_ref ref; |
| 1650 | if (get_ref_for_path(item->Label(), &ref) == B_OK) { |
| 1651 | _HandleResolveMissingSourceFile(ref); |
| 1652 | return; |
| 1653 | } |
| 1654 | } |
| 1655 | } |
| 1656 | |
| 1657 | try { |
| 1658 | if (fFilePanel == NULL) { |
| 1659 | fFilePanel = new BFilePanel(B_OPEN_PANEL, |
| 1660 | new BMessenger(this)); |
| 1661 | } |
| 1662 | fFilePanel->Show(); |
| 1663 | } catch (...) { |
| 1664 | delete fFilePanel; |
| 1665 | fFilePanel = NULL; |
| 1666 | } |
| 1667 | } |
| 1668 | |
| 1669 | |