mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 12:46:35 +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:
parent
457ba3665e
commit
e9a9a768cc
@ -90,12 +90,6 @@ WebTab* TabbedWebView::webTab() const
|
|||||||
return m_webTab;
|
return m_webTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
TabWidget* TabbedWebView::tabWidget() const
|
|
||||||
{
|
|
||||||
// FIXME:!!
|
|
||||||
return m_window ? m_window->tabWidget() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString TabbedWebView::getIp() const
|
QString TabbedWebView::getIp() const
|
||||||
{
|
{
|
||||||
return m_currentIp;
|
return m_currentIp;
|
||||||
@ -222,13 +216,15 @@ void TabbedWebView::closeView()
|
|||||||
|
|
||||||
void TabbedWebView::openNewTab()
|
void TabbedWebView::openNewTab()
|
||||||
{
|
{
|
||||||
tabWidget()->addView(QUrl());
|
if (m_window) {
|
||||||
|
m_window->tabWidget()->addView(QUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position)
|
void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags position)
|
||||||
{
|
{
|
||||||
if (m_window) {
|
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)->webTab()->locationBar()->showUrl(req.url());
|
||||||
m_window->weView(index)->load(req);
|
m_window->weView(index)->load(req);
|
||||||
}
|
}
|
||||||
@ -236,7 +232,9 @@ void TabbedWebView::loadInNewTab(const LoadRequest &req, Qz::NewTabPositionFlags
|
|||||||
|
|
||||||
void TabbedWebView::setAsCurrentTab()
|
void TabbedWebView::setAsCurrentTab()
|
||||||
{
|
{
|
||||||
tabWidget()->setCurrentWidget(m_webTab);
|
if (m_window) {
|
||||||
|
m_window->tabWidget()->setCurrentWidget(m_webTab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabbedWebView::mouseMoveEvent(QMouseEvent* event)
|
void TabbedWebView::mouseMoveEvent(QMouseEvent* event)
|
||||||
|
@ -38,11 +38,11 @@ public:
|
|||||||
|
|
||||||
void setWebPage(WebPage* page);
|
void setWebPage(WebPage* page);
|
||||||
|
|
||||||
|
// BrowserWindow can be null!
|
||||||
BrowserWindow* browserWindow() const;
|
BrowserWindow* browserWindow() const;
|
||||||
void setBrowserWindow(BrowserWindow* window);
|
void setBrowserWindow(BrowserWindow* window);
|
||||||
|
|
||||||
WebTab* webTab() const;
|
WebTab* webTab() const;
|
||||||
TabWidget* tabWidget() const;
|
|
||||||
|
|
||||||
QString getIp() const;
|
QString getIp() const;
|
||||||
int tabIndex() const;
|
int tabIndex() const;
|
||||||
|
@ -244,31 +244,33 @@ void MouseGestures::upDownGestured()
|
|||||||
void MouseGestures::upLeftGestured()
|
void MouseGestures::upLeftGestured()
|
||||||
{
|
{
|
||||||
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
|
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
|
||||||
if (!view) {
|
if (!view)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (QApplication::isRightToLeft()) {
|
BrowserWindow* window = view->browserWindow();
|
||||||
view->tabWidget()->nextTab();
|
if (!window)
|
||||||
}
|
return;
|
||||||
else {
|
|
||||||
view->tabWidget()->previousTab();
|
if (QApplication::isRightToLeft())
|
||||||
}
|
window->tabWidget()->nextTab();
|
||||||
|
else
|
||||||
|
window->tabWidget()->previousTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseGestures::upRightGestured()
|
void MouseGestures::upRightGestured()
|
||||||
{
|
{
|
||||||
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
|
TabbedWebView* view = qobject_cast<TabbedWebView*>(m_view.data());
|
||||||
if (!view) {
|
if (!view)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (QApplication::isRightToLeft()) {
|
BrowserWindow* window = view->browserWindow();
|
||||||
view->tabWidget()->previousTab();
|
if (!window)
|
||||||
}
|
return;
|
||||||
else {
|
|
||||||
view->tabWidget()->nextTab();
|
if (QApplication::isRightToLeft())
|
||||||
}
|
window->tabWidget()->previousTab();
|
||||||
|
else
|
||||||
|
window->tabWidget()->nextTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseGestures::init()
|
void MouseGestures::init()
|
||||||
|
Loading…
Reference in New Issue
Block a user