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()
|
||||
{
|
||||
m_page->load(static_cast<TabbedWebView*>(m_page->view())->browserWindow()->homepageUrl());
|
||||
BrowserWindow *window = getBrowserWindow();
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
m_page->load(window->homepageUrl());
|
||||
|
||||
mApp->destroyRestoreManager();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
BrowserWindow *RecoveryJsObject::getBrowserWindow() const
|
||||
{
|
||||
TabbedWebView *view = qobject_cast<TabbedWebView*>(m_page->view());
|
||||
return view ? view->browserWindow() : Q_NULLPTR;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QObject>
|
||||
|
||||
class WebPage;
|
||||
class BrowserWindow;
|
||||
class RestoreManager;
|
||||
|
||||
class RecoveryJsObject : public QObject
|
||||
|
@ -37,6 +38,8 @@ public slots:
|
|||
void restoreSession();
|
||||
|
||||
private:
|
||||
BrowserWindow *getBrowserWindow() const;
|
||||
|
||||
RestoreManager *m_manager;
|
||||
WebPage *m_page;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user