aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browser.h6
-rw-r--r--src/main.cpp29
-rw-r--r--src/mainwindow/mainwindow.cpp10
-rw-r--r--src/session.cpp16
-rw-r--r--src/session.h7
5 files changed, 58 insertions, 10 deletions
diff --git a/src/browser.h b/src/browser.h
index c82afa0..694a3a7 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -15,6 +15,7 @@
#include <functional>
#include <interfaces.h>
#include <memory>
+#include "session.h"
QVector<Plugin> loadPlugins(const QString &location);
@@ -48,9 +49,8 @@ public:
void setup(const QString &defaultProfile);
- std::shared_ptr<BookmarksWidget> bookmarks()
- {
- return m_bookmarks;
+ QJsonObject session() const {
+ return JsonSession::session(m_windows);
}
public slots:
diff --git a/src/main.cpp b/src/main.cpp
index f3ddeb9..e7fdcee 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,22 +22,34 @@
#endif
#ifdef BreakpadEnabled
+#ifdef Q_OS_LINUX
#include <client/linux/handler/exception_handler.h>
+// bool filter_callback (void*)
+// --> true: continue processing and write a minidump
+
static bool dumpCallback(const google_breakpad::MinidumpDescriptor &descriptor, void *context, bool succeeded)
{
printf("Dump path: %s\n", descriptor.path());
+
+ if(auto *app = static_cast<Browser *>(context); app != nullptr) {
+ auto session = app->session();
+ QJsonDocument doc(session);
+ QFile sessionFile(QString("%1.json").arg(QString::fromStdString(descriptor.path())));
+ if(sessionFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ sessionFile.write(qUtf8Printable(doc.toJson()));
+ sessionFile.flush();
+ sessionFile.close();
+ }
+ }
+
return succeeded;
}
+#endif // Q_OS_LINUX
#endif
int main(int argc, char **argv)
{
-#ifdef BreakpadEnabled
- google_breakpad::MinidumpDescriptor descriptor("/tmp");
- google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, true, -1);
-#endif
-
// a beautiful hack to be able to write to stdout on Windows
#ifdef _WIN32
if(AttachConsole(ATTACH_PARENT_PROCESS)) {
@@ -116,6 +128,13 @@ int main(int argc, char **argv)
// set this, otherwise the webview becomes black when using a stylesheet
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
+#ifdef BreakpadEnabled
+ google_breakpad::MinidumpDescriptor descriptor("/tmp");
+
+ // minidump descriptor, filter callback, minidump callback, callback_context, install handler, server_fd
+ google_breakpad::ExceptionHandler eh(descriptor, nullptr, dumpCallback, &app, true, -1);
+#endif
+
// translator
if(config->exists("browser.locale")) {
auto *translator = new QTranslator(&app);
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 77b8ad3..cc67b3d 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -89,6 +89,16 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
}
show();
+#ifdef QT_DEBUG
+ {
+ auto *debugMenu = ui->menubar->addMenu(tr("Debug"));
+
+ debugMenu->addAction(tr("Crash"), []() {
+ delete reinterpret_cast<QString*>(0xFEE1DEAD);
+ });
+ };
+#endif
+
// connect smolbote menu
{
connect(ui->actionNewSubwindow, &QAction::triggered, this, [this, &config]() {
diff --git a/src/session.cpp b/src/session.cpp
index e1f600a..9c69088 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -14,11 +14,25 @@
#include "webengine/webview.h"
#include <web/profilemanager.h>
+
+QJsonObject JsonSession::session(QVector<MainWindow *> windows)
+{
+ QJsonObject obj;
+
+ QJsonArray windowsArray;
+ for(const MainWindow *window : windows) {
+ windowsArray.append(Session::toJsonObject(window));
+ }
+ obj.insert("windows", windowsArray);
+
+ return obj;
+}
+
Session::Session(QObject *parent) : QObject(parent)
{
}
-QJsonObject Session::toJsonObject(MainWindow *window)
+QJsonObject Session::toJsonObject(const MainWindow *window)
{
QJsonObject session;
diff --git a/src/session.h b/src/session.h
index 4d5d59b..c81b2bf 100644
--- a/src/session.h
+++ b/src/session.h
@@ -13,13 +13,18 @@
#include <QJsonDocument>
class MainWindow;
+
+namespace JsonSession {
+QJsonObject session(QVector<MainWindow *> windows);
+}
+
class Session : public QObject
{
Q_OBJECT
public:
explicit Session(QObject *parent = nullptr);
- static QJsonObject toJsonObject(MainWindow *window);
+ static QJsonObject toJsonObject(const MainWindow *window);
static QJsonObject toJsonObject(const QString &profile, const QStringList &urls);
signals: