mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
RecoveryJsObject: Use safer method to get BrowserWindow from WebPage
This commit is contained in:
parent
fc85caff57
commit
a9d0e79eeb
|
@ -38,14 +38,29 @@ void RecoveryJsObject::setPage(WebPage *page)
|
||||||
|
|
||||||
void RecoveryJsObject::startNewSession()
|
void RecoveryJsObject::startNewSession()
|
||||||
{
|
{
|
||||||
m_page->load(static_cast<TabbedWebView*>(m_page->view())->browserWindow()->homepageUrl());
|
BrowserWindow *window = getBrowserWindow();
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_page->load(window->homepageUrl());
|
||||||
|
|
||||||
mApp->destroyRestoreManager();
|
mApp->destroyRestoreManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecoveryJsObject::restoreSession()
|
void RecoveryJsObject::restoreSession()
|
||||||
{
|
{
|
||||||
if (!mApp->restoreSession(static_cast<TabbedWebView*>(m_page->view())->browserWindow() , m_manager->restoreData())) {
|
BrowserWindow *window = getBrowserWindow();
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool ok = mApp->restoreSession(window , m_manager->restoreData());
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
startNewSession();
|
startNewSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BrowserWindow *RecoveryJsObject::getBrowserWindow() const
|
||||||
|
{
|
||||||
|
TabbedWebView *view = qobject_cast<TabbedWebView*>(m_page->view());
|
||||||
|
return view ? view->browserWindow() : Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class WebPage;
|
class WebPage;
|
||||||
|
class BrowserWindow;
|
||||||
class RestoreManager;
|
class RestoreManager;
|
||||||
|
|
||||||
class RecoveryJsObject : public QObject
|
class RecoveryJsObject : public QObject
|
||||||
|
@ -37,6 +38,8 @@ public slots:
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BrowserWindow *getBrowserWindow() const;
|
||||||
|
|
||||||
RestoreManager *m_manager;
|
RestoreManager *m_manager;
|
||||||
WebPage *m_page;
|
WebPage *m_page;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user