aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-05-28 22:05:45 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2020-05-29 14:33:05 +0300
commit149043a24273e5f02ed921e33c256567156fa95a (patch)
tree9cf19007a2dd055e75fb8d9d2335737ae90fb333 /src/webengine
parentTurn on more warnings by default (diff)
downloadsmolbote-149043a24273e5f02ed921e33c256567156fa95a.tar.xz
Fix segfault in release build
When creating a WebView out of a Session struct, fall back to the default profile if one is not set, or a profile with that ID is not found. - Update PKGBUILD
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/webprofile.cpp2
-rw-r--r--src/webengine/webprofilemanager.h13
-rw-r--r--src/webengine/webview.cpp14
3 files changed, 11 insertions, 18 deletions
diff --git a/src/webengine/webprofile.cpp b/src/webengine/webprofile.cpp
index 719ab34..f1e71fb 100644
--- a/src/webengine/webprofile.cpp
+++ b/src/webengine/webprofile.cpp
@@ -18,12 +18,10 @@ static WebProfile *s_profile = nullptr;
void WebProfile::setDefaultProfile(WebProfile *profile)
{
- Q_CHECK_PTR(profile);
s_profile = profile;
}
WebProfile *WebProfile::defaultProfile()
{
- Q_CHECK_PTR(s_profile);
return s_profile;
}
diff --git a/src/webengine/webprofilemanager.h b/src/webengine/webprofilemanager.h
index 91dcaf8..a356506 100644
--- a/src/webengine/webprofilemanager.h
+++ b/src/webengine/webprofilemanager.h
@@ -41,10 +41,11 @@ public:
}
if(!profiles.contains(default_id)) {
- Profile profile;
- profile.settings = WebProfile::load(QString(), search, homepage, newtab);
- profile.ptr = WebProfile::load(default_id, profile.settings, true);
- profiles[default_id] = profile;
+ auto *settings = WebProfile::load(QString(), search, homepage, newtab);
+ profiles[default_id] = Profile{
+ .settings = settings,
+ .ptr = WebProfile::load(default_id, settings, true),
+ };
}
WebProfile::setDefaultProfile(profiles[default_id].ptr);
}
@@ -73,7 +74,7 @@ public:
}
if(profile != nullptr && settings != nullptr) {
- profiles[id] = Profile{ profile, settings, false };
+ profiles[id] = Profile{ settings, profile, false };
}
}
@@ -101,8 +102,8 @@ private:
set_typestate(consumed) void consume() {}
struct Profile {
- WebProfile *ptr = nullptr;
QSettings *settings = nullptr;
+ WebProfile *ptr = nullptr;
bool selfDestruct = false;
};
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 38e564a..bc52102 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -37,9 +37,7 @@ WebView::WebView(WebProfile *profile, cb_createWindow_t cb, QWidget *parent)
: WebView(parent)
{
cb_createWindow = cb;
- Q_CHECK_PTR(profile);
- m_profile = profile;
- setPage(new WebPage(profile, this));
+ setProfile(profile);
}
WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWidget *parent)
@@ -47,11 +45,7 @@ WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWi
{
cb_createWindow = cb;
WebProfileManager profileManager;
-
- auto *profile = profileManager.profile(webview_data.profile);
- if(profile != nullptr) {
- setProfile(profile);
- }
+ setProfile(profileManager.profile(webview_data.profile));
if(!webview_data.url.isEmpty())
load(QUrl::fromUserInput(webview_data.url));
@@ -64,9 +58,9 @@ WebView::WebView(const Session::WebView &webview_data, cb_createWindow_t cb, QWi
void WebView::setProfile(WebProfile *profile)
{
- m_profile = profile;
+ m_profile = (profile == nullptr) ? WebProfile::defaultProfile() : profile;
const auto url = this->url();
- setPage(new WebPage(profile, this));
+ setPage(new WebPage(m_profile, this));
this->load(url);
}