[haiku-webkit-commits] r522 - in webkit/trunk/WebKit/haiku/WebPositive: . tabview

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Mon, 14 Jun 2010 15:19:37 +0000

Author: stippi
Date: Mon Jun 14 15:19:36 2010
New Revision: 522
URL: http://mmlr.dyndns.org/changeset/522

Log:
* 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.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.cpp
   webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.h

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Sun May 30 
20:46:40 2010        (r521)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Mon Jun 14 
15:19:36 2010        (r522)
@@ -1245,12 +1245,12 @@
 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 @@
 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);
 }
 

Modified: webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.cpp        Sun May 
30 20:46:40 2010        (r521)
+++ webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.cpp        Mon Jun 
14 15:19:36 2010        (r522)
@@ -746,6 +746,13 @@
 }
 
 
+bool
+TabManager::HasView(const BView* containedView) const
+{
+       return TabForView(containedView) >= 0;
+}
+
+
 void
 TabManager::SelectTab(int32 tabIndex)
 {

Modified: webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.h  Sun May 30 
20:46:40 2010        (r521)
+++ webkit/trunk/WebKit/haiku/WebPositive/tabview/TabManager.h  Mon Jun 14 
15:19:36 2010        (r522)
@@ -63,6 +63,7 @@
 
                        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);

Other related posts:

  • » [haiku-webkit-commits] r522 - in webkit/trunk/WebKit/haiku/WebPositive: . tabview - webkit