1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[TabbedWebView] Make sure to not crash with invalid m_window pointer

This is followup to properly handle detached WebTab (outside
BrowserWindow)

[ci skip]
This commit is contained in:
David Rosca 2014-04-11 22:23:42 +02:00
parent 457ba3665e
commit e9a9a768cc
3 changed files with 26 additions and 26 deletions

View File

@ -90,12 +90,6 @@ WebTab* TabbedWebView::webTab() const
return m_webTab;
}
TabWidget* TabbedWebView::tabWidget() const
{
// FIXME:!!
return m_window ? m_window->tabWidget() : 0;
}
QString TabbedWebView::getIp() const
{
return m_currentIp;
@ -222,13 +216,15 @@ void TabbedWebView::closeView()
void TabbedWebView::openNewTab()
{
tabWidget()->addView(QUrl());
if (m_window) {
m_window->tabWidget()->addView(QUrl());
}
}
void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position)
{
if (m_window) {
int index = tabWidget()->addView(QUrl(), position);
int index = m_window->tabWidget()->addView(QUrl(), position);
m_window->weView(index)->webTab()->locationBar()->showUrl(req.url());
m_window->weView(index)->load(req);
}
@ -236,7 +232,9 @@ void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags
void TabbedWebView::setAsCurrentTab()
{
tabWidget()->setCurrentWidget(m_webTab);
if (m_window) {
m_window->tabWidget()->setCurrentWidget(m_webTab);
}
}
void TabbedWebView::mouseMoveEvent(QMouseEvent* event)

View File

@ -38,11 +38,11 @@ public:
void setWebPage(WebPage* page);
// BrowserWindow can be null!
BrowserWindow* browserWindow() const;
void setBrowserWindow(BrowserWindow* window);
WebTab* webTab() const;
TabWidget* tabWidget() const;
QString getIp() const;
int tabIndex() const;

View File

@ -244,31 +244,33 @@ void MouseGestures::upDownGestured()
void MouseGestures::upLeftGestured()
{
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
if (!view) {
if (!view)
return;
}
if (QApplication::isRightToLeft()) {
view->tabWidget()->nextTab();
}
else {
view->tabWidget()->previousTab();
}
BrowserWindow* window = view->browserWindow();
if (!window)
return;
if (QApplication::isRightToLeft())
window->tabWidget()->nextTab();
else
window->tabWidget()->previousTab();
}
void MouseGestures::upRightGestured()
{
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
if (!view) {
if (!view)
return;
}
if (QApplication::isRightToLeft()) {
view->tabWidget()->previousTab();
}
else {
view->tabWidget()->nextTab();
}
BrowserWindow* window = view->browserWindow();
if (!window)
return;
if (QApplication::isRightToLeft())
window->tabWidget()->previousTab();
else
window->tabWidget()->nextTab();
}
void MouseGestures::init()