Prevent crash deleting s_dialogParent
This commit is contained in:
parent
4040a4e136
commit
4078e6ff2a
|
@ -57,7 +57,7 @@ using namespace std;
|
|||
|
||||
namespace QtGui {
|
||||
|
||||
std::unique_ptr<QWidget> TrayWidget::s_dialogParent;
|
||||
QWidget *TrayWidget::s_dialogParent = nullptr;
|
||||
SettingsDialog *TrayWidget::s_settingsDlg = nullptr;
|
||||
QtUtilities::AboutDialog *TrayWidget::s_aboutDlg = nullptr;
|
||||
vector<TrayWidget *> TrayWidget::s_instances;
|
||||
|
@ -212,6 +212,7 @@ TrayWidget::~TrayWidget()
|
|||
s_instances.erase(i);
|
||||
}
|
||||
if (s_instances.empty()) {
|
||||
delete s_dialogParent;
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
}
|
||||
|
@ -219,10 +220,10 @@ TrayWidget::~TrayWidget()
|
|||
void TrayWidget::showSettingsDialog()
|
||||
{
|
||||
if (!s_dialogParent) {
|
||||
s_dialogParent = make_unique<QWidget>();
|
||||
s_dialogParent = new QWidget();
|
||||
}
|
||||
if (!s_settingsDlg) {
|
||||
s_settingsDlg = new SettingsDialog(s_instances.size() < 2 ? &m_connection : nullptr, s_dialogParent.get());
|
||||
s_settingsDlg = new SettingsDialog(s_instances.size() < 2 ? &m_connection : nullptr, s_dialogParent);
|
||||
connect(s_settingsDlg, &SettingsDialog::applied, &TrayWidget::applySettingsOnAllInstances);
|
||||
|
||||
// save settings to disk when applied
|
||||
|
@ -238,10 +239,10 @@ void TrayWidget::showSettingsDialog()
|
|||
void TrayWidget::showAboutDialog()
|
||||
{
|
||||
if (!s_dialogParent) {
|
||||
s_dialogParent = make_unique<QWidget>();
|
||||
s_dialogParent = new QWidget();
|
||||
}
|
||||
if (!s_aboutDlg) {
|
||||
s_aboutDlg = new AboutDialog(s_dialogParent.get(), QString(),
|
||||
s_aboutDlg = new AboutDialog(s_dialogParent, QString(),
|
||||
QStringLiteral(
|
||||
"<p>Developed by " APP_AUTHOR
|
||||
"<br>Fallback icons from KDE/Breeze project<br>Syncthing icons from <a href=\"https://syncthing.net\">Syncthing project</a><br>Using "
|
||||
|
|
|
@ -106,7 +106,7 @@ private Q_SLOTS:
|
|||
private:
|
||||
TrayMenu *m_menu;
|
||||
std::unique_ptr<Ui::TrayWidget> m_ui;
|
||||
static std::unique_ptr<QWidget> s_dialogParent;
|
||||
static QWidget *s_dialogParent;
|
||||
static SettingsDialog *s_settingsDlg;
|
||||
static QtUtilities::AboutDialog *s_aboutDlg;
|
||||
#ifndef SYNCTHINGWIDGETS_NO_WEBVIEW
|
||||
|
|
Loading…
Reference in New Issue