Fix crash in Group Edit after enabling Browser Integration (#8778)

Fixes https://github.com/keepassxreboot/keepassxc/issues/8775
This commit is contained in:
Sami Vänttinen 2022-12-19 05:56:00 +02:00 committed by GitHub
parent 2dbb29fc85
commit ad773c567d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 164 additions and 178 deletions

View File

@ -3084,10 +3084,6 @@ Would you like to correct it?</source>
</context>
<context>
<name>EditGroupWidgetBrowser</name>
<message>
<source>Edit Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>These settings affect to the group&apos;s behaviour with the browser extension.</source>
<translation type="unfinished"></translation>

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -73,7 +73,7 @@ EditGroupWidget::EditGroupWidget(QWidget* parent)
#if defined(WITH_XC_BROWSER)
, m_browserSettingsChanged(false)
, m_browserUi(new Ui::EditGroupWidgetBrowser())
, m_browserWidget(new QScrollArea())
, m_browserWidget(new QWidget(this))
#endif
, m_group(nullptr)
{
@ -83,8 +83,7 @@ EditGroupWidget::EditGroupWidget(QWidget* parent)
addPage(tr("Icon"), icons()->icon("preferences-desktop-icons"), m_editGroupWidgetIcons);
#if defined(WITH_XC_BROWSER)
if (config()->get(Config::Browser_Enabled).toBool()) {
addPage(tr("Browser Integration"), icons()->icon("internet-web-browser"), m_browserWidget);
m_browserUi->setupUi(m_browserWidget);
initializeBrowserPage();
}
#endif
#if defined(WITH_XC_KEESHARE)
@ -135,28 +134,7 @@ void EditGroupWidget::setupModifiedTracking()
#if defined(WITH_XC_BROWSER)
if (config()->get(Config::Browser_Enabled).toBool()) {
// Browser integration tab
connect(
m_browserUi->browserIntegrationHideEntriesComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified()));
connect(m_browserUi->browserIntegrationSkipAutoSubmitComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(setModified()));
connect(
m_browserUi->browserIntegrationOnlyHttpAuthComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified()));
connect(
m_browserUi->browserIntegrationNotHttpAuthComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified()));
connect(m_browserUi->browserIntegrationHideEntriesComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
connect(m_browserUi->browserIntegrationSkipAutoSubmitComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
connect(m_browserUi->browserIntegrationOnlyHttpAuthComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
connect(m_browserUi->browserIntegrationNotHttpAuthComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
setupBrowserModifiedTracking();
}
#endif
}
@ -230,6 +208,14 @@ void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer<
inheritOmitWww = parent->resolveCustomDataTriState(BrowserService::OPTION_OMIT_WWW);
}
// If the page has not been created at all, some of the elements are null
if (m_browserUi->browserIntegrationHideEntriesComboBox == nullptr
&& config()->get(Config::Browser_Enabled).toBool()) {
initializeBrowserPage();
setupBrowserModifiedTracking();
}
setPageHidden(m_browserWidget, false);
addTriStateItems(m_browserUi->browserIntegrationHideEntriesComboBox, inheritHideEntries);
addTriStateItems(m_browserUi->browserIntegrationSkipAutoSubmitComboBox, inheritSkipSubmit);
addTriStateItems(m_browserUi->browserIntegrationOnlyHttpAuthComboBox, inheritOnlyHttp);
@ -246,6 +232,8 @@ void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer<
indexFromTriState(group->resolveCustomDataTriState(BrowserService::OPTION_NOT_HTTP_AUTH, false)));
m_browserUi->browserIntegrationOmitWwwCombobox->setCurrentIndex(
indexFromTriState(group->resolveCustomDataTriState(BrowserService::OPTION_OMIT_WWW, false)));
} else if (hasPage(m_browserWidget)) {
setPageHidden(m_browserWidget, true);
}
#endif
@ -363,6 +351,34 @@ void EditGroupWidget::cancel()
}
#ifdef WITH_XC_BROWSER
void EditGroupWidget::initializeBrowserPage()
{
addPage(tr("Browser Integration"), icons()->icon("internet-web-browser"), m_browserWidget);
m_browserUi->setupUi(m_browserWidget);
}
void EditGroupWidget::setupBrowserModifiedTracking()
{
// Browser integration tab
connect(m_browserUi->browserIntegrationHideEntriesComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified()));
connect(
m_browserUi->browserIntegrationSkipAutoSubmitComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified()));
connect(m_browserUi->browserIntegrationOnlyHttpAuthComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified()));
connect(m_browserUi->browserIntegrationNotHttpAuthComboBox, SIGNAL(currentIndexChanged(int)), SLOT(setModified()));
connect(m_browserUi->browserIntegrationHideEntriesComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
connect(m_browserUi->browserIntegrationSkipAutoSubmitComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
connect(m_browserUi->browserIntegrationOnlyHttpAuthComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
connect(m_browserUi->browserIntegrationNotHttpAuthComboBox,
SIGNAL(currentIndexChanged(int)),
SLOT(updateBrowserModified()));
}
void EditGroupWidget::updateBrowserModified()
{
m_browserSettingsChanged = true;

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2021 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -72,6 +72,8 @@ private slots:
void save();
void cancel();
#ifdef WITH_XC_BROWSER
void initializeBrowserPage();
void setupBrowserModifiedTracking();
void updateBrowserModified();
#endif
@ -89,7 +91,7 @@ private:
#ifdef WITH_XC_BROWSER
bool m_browserSettingsChanged;
const QScopedPointer<Ui::EditGroupWidgetBrowser> m_browserUi;
QPointer<QScrollArea> m_browserWidget;
QWidget* const m_browserWidget;
#endif
QScopedPointer<Group> m_temporaryGroup;

View File

@ -1,34 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditGroupWidgetBrowser</class>
<widget class="QScrollArea" name="EditGroupWidgetBrowser">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>539</width>
<height>523</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit Group</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="container">
<widget class="QWidget" name="EditGroupWidgetBrowser">
<property name="geometry">
<rect>
<x>0</x>
@ -59,126 +32,125 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,1" columnstretch="0,1" rowminimumheight="0,0,0,1">
   <property name="leftMargin">
   <number>0</number>
   </property>
   <property name="topMargin">
   <number>10</number>
   </property>
   <property name="rightMargin">
   <number>0</number>
   </property>
   <property name="bottomMargin">
  <number>0</number>
  </property>
  <property name="horizontalSpacing">
  <number>10</number>
  </property>
  <property name="verticalSpacing">
  <number>8</number>
  </property>
  <item row="0" column="0">
  <widget class="QLabel" name="browserIntegrationHideEntriesLabel">
  <property name="text">
  <string>Hide entries from browser extension:</string>
  </property>
  <property name="alignment">
  <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
  </property>
  </widget>
  </item>
  <item row="0" column="1">
  <widget class="QComboBox" name="browserIntegrationHideEntriesComboBox">
  <property name="accessibleName">
  <string>Hide entries from browser extension toggle for this and sub groups</string>
  </property>
  </widget>
  </item>
  <item row="1" column="0">
  <widget class="QLabel" name="browserIntegrationSkipAutoSubmitLabel">
  <property name="text">
  <string>Skip Auto-Submit for entries:</string>
  </property>
  <property name="alignment">
  <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
  </property>
  </widget>
  </item>
  <item row="1" column="1">
  <widget class="QComboBox" name="browserIntegrationSkipAutoSubmitComboBox">
  <property name="accessibleName">
  <string>Skip Auto-Submit toggle for this and sub groups</string>
  </property>
  </widget>
  </item>
  <item row="2" column="0">
  <widget class="QLabel" name="browserIntegrationOnlyHttpAuthLabel">
  <property name="text">
  <string>Use entries only with HTTP Basic Auth:</string>
  </property>
  <property name="alignment">
  <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
  </property>
  </widget>
  </item>
  <item row="2" column="1">
  <widget class="QComboBox" name="browserIntegrationOnlyHttpAuthComboBox">
  <property name="accessibleName">
  <string>Only HTTP Auth toggle for this and sub groups</string>
  </property>
  </widget>
  </item>
  <item row="3" column="0">
   <widget class="QLabel" name="browserIntegrationNotHttpAuthLabel">
   <property name="text">
   <string>Do not use entries with HTTP Basic Auth:</string>
   </property>
   <property name="alignment">
   <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
   </property>
   </widget>
   </item>
   <item row="3" column="1">
   <widget class="QComboBox" name="browserIntegrationNotHttpAuthComboBox">
   <property name="accessibleName">
   <string>Do not use HTTP Auth toggle for this and sub groups</string>
   </property>
   </widget>
   </item>
<item row="4" column="0">
   <widget class="QLabel" name="browserIntegrationOmitWwwLabel">
   <property name="text">
   <string>Omit WWW subdomain from matching:</string>
   </property>
   <property name="alignment">
   <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
   </property>
   </widget>
   </item>
   <item row="4" column="1">
   <widget class="QComboBox" name="browserIntegrationOmitWwwCombobox">
   <property name="accessibleName">
   <string>Omit WWW subdomain from matching toggle for this and sub groups</string>
   </property>
   </widget>
   </item>
   <item row="5" column="0">
   <spacer name="verticalSpacer_1">
   <property name="orientation">
   <enum>Qt::Vertical</enum>
   </property>
   <property name="sizeHint" stdset="0">
   <size>
   <width>20</width>
   <height>40</height>
  </size>
  </property>
  </spacer>
  </item>
  </layout>
 </item>
</layout>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>10</number>
</property>
<property name="verticalSpacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="browserIntegrationHideEntriesLabel">
<property name="text">
<string>Hide entries from browser extension:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="browserIntegrationHideEntriesComboBox">
<property name="accessibleName">
<string>Hide entries from browser extension toggle for this and sub groups</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="browserIntegrationSkipAutoSubmitLabel">
<property name="text">
<string>Skip Auto-Submit for entries:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="browserIntegrationSkipAutoSubmitComboBox">
<property name="accessibleName">
<string>Skip Auto-Submit toggle for this and sub groups</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="browserIntegrationOnlyHttpAuthLabel">
<property name="text">
<string>Use entries only with HTTP Basic Auth:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="browserIntegrationOnlyHttpAuthComboBox">
<property name="accessibleName">
<string>Only HTTP Auth toggle for this and sub groups</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="browserIntegrationNotHttpAuthLabel">
<property name="text">
<string>Do not use entries with HTTP Basic Auth:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="browserIntegrationNotHttpAuthComboBox">
<property name="accessibleName">
<string>Do not use HTTP Auth toggle for this and sub groups</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="browserIntegrationOmitWwwLabel">
<property name="text">
<string>Omit WWW subdomain from matching:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="browserIntegrationOmitWwwCombobox">
<property name="accessibleName">
<string>Omit WWW subdomain from matching toggle for this and sub groups</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>browserIntegrationHideEntriesComboBox</tabstop>