* Small cleanups.

* Make sure that the BWebView for which a notification is received still exists.
  This affected only the title changed notification, for which this was already
  checked, and the icon received notification, which could actually lead to
  a crash if the tab was closed before receiving the notification.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@522 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-06-14 15:19:36 +00:00 committed by Alexandre Deckner
parent 591220f9b2
commit ed0c70c14d
3 changed files with 19 additions and 6 deletions

View File

@ -1245,12 +1245,12 @@ BrowserWindow::MainDocumentError(const BString& failingURL,
void
BrowserWindow::TitleChanged(const BString& title, BWebView* view)
{
for (int32 i = 0; i < fTabManager->CountTabs(); i++) {
if (fTabManager->ViewForTab(i) == view) {
fTabManager->SetTabLabel(i, title);
break;
}
}
int32 tabIndex = fTabManager->TabForView(view);
if (tabIndex < 0)
return;
fTabManager->SetTabLabel(tabIndex, title);
if (view != CurrentWebView())
return;
@ -1261,6 +1261,11 @@ BrowserWindow::TitleChanged(const BString& title, BWebView* view)
void
BrowserWindow::IconReceived(const BBitmap* icon, BWebView* view)
{
// The view may already be gone, since this notification arrives
// asynchronously.
if (!fTabManager->HasView(view))
return;
_SetPageIcon(view, icon);
}

View File

@ -746,6 +746,13 @@ TabManager::TabForView(const BView* containedView) const
}
bool
TabManager::HasView(const BView* containedView) const
{
return TabForView(containedView) >= 0;
}
void
TabManager::SelectTab(int32 tabIndex)
{

View File

@ -63,6 +63,7 @@ public:
BView* ViewForTab(int32 tabIndex) const;
int32 TabForView(const BView* containedView) const;
bool HasView(const BView* containedView) const;
void SelectTab(int32 tabIndex);
void SelectTab(const BView* containedView);