From 75845de732ffa2ca970d6b9d4e1197769616ee7e Mon Sep 17 00:00:00 2001 From: anevilyak Date: Sat, 20 Feb 2010 19:52:10 +0000 Subject: [PATCH] Add mechanism for asking LauncherApp to create a web view to ensure new view creation always happens in the main thread. Fixes assert failure when creating a new tab with debug builds. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@155 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/LauncherApp.cpp | 6 ++++++ src/apps/webpositive/LauncherApp.h | 4 ++++ src/apps/webpositive/LauncherWindow.cpp | 13 ++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/apps/webpositive/LauncherApp.cpp b/src/apps/webpositive/LauncherApp.cpp index 4f01619717..367894b11a 100644 --- a/src/apps/webpositive/LauncherApp.cpp +++ b/src/apps/webpositive/LauncherApp.cpp @@ -165,6 +165,12 @@ void LauncherApp::MessageReceived(BMessage* message) newWindow(url); break; } + case CREATE_WEBVIEW: { + BMessage reply; + reply.AddPointer("view", new WebView("web_view")); + message->SendReply(&reply); + break; + } case WINDOW_OPENED: m_windowCount++; break; diff --git a/src/apps/webpositive/LauncherApp.h b/src/apps/webpositive/LauncherApp.h index 636169c4a5..8be0c4ebb1 100644 --- a/src/apps/webpositive/LauncherApp.h +++ b/src/apps/webpositive/LauncherApp.h @@ -36,6 +36,10 @@ class BFile; class DownloadWindow; class LauncherWindow; +enum { + CREATE_WEBVIEW = 'crwb' +}; + class LauncherApp : public BApplication { public: LauncherApp(); diff --git a/src/apps/webpositive/LauncherWindow.cpp b/src/apps/webpositive/LauncherWindow.cpp index 92ec37d911..12c5c460e9 100644 --- a/src/apps/webpositive/LauncherWindow.cpp +++ b/src/apps/webpositive/LauncherWindow.cpp @@ -35,6 +35,7 @@ #include "AuthenticationPanel.h" #include "BrowsingHistory.h" +#include "LauncherApp.h" #include "WebPage.h" #include "WebTabView.h" #include "WebView.h" @@ -329,9 +330,14 @@ void LauncherWindow::MessageReceived(BMessage* message) case NEW_TAB: { - m_tabView->AddTab(new WebView("web_view")); + BMessage reply; + be_app_messenger.SendMessage(CREATE_WEBVIEW, &reply); + WebView *view = NULL; + reply.FindPointer("view", reinterpret_cast(&view)); + m_tabView->AddTab(view); m_tabView->TabAt(m_tabView->CountTabs() - 1)->SetLabel("New Tab"); m_tabView->Select(m_tabView->CountTabs() - 1); + navigationCapabilitiesChanged(false, false, false, currentWebView()); break; } @@ -350,6 +356,11 @@ void LauncherWindow::MessageReceived(BMessage* message) m_tabView->ViewForTab(index))); updateTitle(m_tabView->TabAt(index)->Label()); m_url->TextView()->SetText(currentWebView()->mainFrameURL()); + BWebPage *page = currentWebView()->webPage(); +// bool canGoForward = page->CanGoInDirection(1); +// bool canGoBackward = page->CanGoInDirection(-1); +// navigationCapabilitiesChanged(canGoForward, canGoBackward, false, +// currentWebView()); break; }