use invoking when displaying messageboxes to avoid crashes when called directly from non-gui thread

This commit is contained in:
Martin Rotter 2023-07-26 06:52:02 +02:00
parent 8ecff5763b
commit 48ed8497ea
2 changed files with 27 additions and 6 deletions

View file

@ -670,9 +670,9 @@ void Application::deleteTrayIcon() {
}
}
void Application::showGuiMessage(Notification::Event event,
void Application::showGuiMessageCore(Notification::Event event,
const GuiMessage& msg,
const GuiMessageDestination& dest,
GuiMessageDestination dest,
const GuiAction& action,
QWidget* parent) {
if (SystemTrayIcon::areNotificationsEnabled()) {
@ -714,6 +714,21 @@ void Application::showGuiMessage(Notification::Event event,
}
}
void Application::showGuiMessage(Notification::Event event,
const GuiMessage& msg,
GuiMessageDestination dest,
const GuiAction& action,
QWidget* parent) {
QMetaObject::invokeMethod(this,
"showGuiMessageCore",
Qt::ConnectionType::QueuedConnection,
Q_ARG(Notification::Event, event),
Q_ARG(const GuiMessage&, msg),
Q_ARG(GuiMessageDestination, dest),
Q_ARG(const GuiAction&, action),
Q_ARG(QWidget*, parent));
}
WebViewer* Application::createWebView() {
#if !defined(USE_WEBENGINE)
return new TextBrowserViewer();

View file

@ -163,7 +163,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
// or in message box if tray icon is disabled.
void showGuiMessage(Notification::Event event,
const GuiMessage& msg,
const GuiMessageDestination& dest = {},
GuiMessageDestination dest = {},
const GuiAction& action = {},
QWidget* parent = nullptr);
@ -193,6 +193,12 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
void displayLog();
void showGuiMessageCore(Notification::Event event,
const GuiMessage& msg,
GuiMessageDestination dest = {},
const GuiAction& action = {},
QWidget* parent = nullptr);
private slots:
void fillCmdArgumentsParser(QCommandLineParser& parser);