Fix double password edit field

This commit is contained in:
Janek Bevendorff 2019-04-02 22:32:48 +02:00
parent f49a8a7f70
commit e025444c86
2 changed files with 9 additions and 12 deletions

View File

@ -168,25 +168,20 @@ void KeyComponentWidget::cancelEdit()
void KeyComponentWidget::showEvent(QShowEvent* event) void KeyComponentWidget::showEvent(QShowEvent* event)
{ {
QWidget::showEvent(event);
resetComponentEditWidget(); resetComponentEditWidget();
QWidget::showEvent(event);
} }
void KeyComponentWidget::resetComponentEditWidget() void KeyComponentWidget::resetComponentEditWidget()
{ {
if (m_ui->componentWidgetLayout->isEmpty() || static_cast<Page>(m_ui->stackedWidget->currentIndex()) == Page::Edit) { if (!m_componentWidget || static_cast<Page>(m_ui->stackedWidget->currentIndex()) == Page::Edit) {
if (!m_ui->componentWidgetLayout->isEmpty()) { if (m_componentWidget) {
auto* item = m_ui->componentWidgetLayout->takeAt(0); delete m_componentWidget;
if (item->widget()) {
delete item->widget();
}
delete item;
} }
QWidget* widget = componentEditWidget(); m_componentWidget = componentEditWidget();
m_ui->componentWidgetLayout->addWidget(widget); m_ui->componentWidgetLayout->addWidget(m_componentWidget);
initComponentEditWidget(m_componentWidget);
initComponentEditWidget(widget);
} }
QTimer::singleShot(0, this, SLOT(updateSize())); QTimer::singleShot(0, this, SLOT(updateSize()));

View File

@ -20,6 +20,7 @@
#include <QScopedPointer> #include <QScopedPointer>
#include <QWidget> #include <QWidget>
#include <QPointer>
namespace Ui namespace Ui
{ {
@ -128,6 +129,7 @@ private:
Page m_previousPage = Page::AddNew; Page m_previousPage = Page::AddNew;
QString m_componentName; QString m_componentName;
QString m_componentDescription; QString m_componentDescription;
QPointer<QWidget> m_componentWidget;
const QScopedPointer<Ui::KeyComponentWidget> m_ui; const QScopedPointer<Ui::KeyComponentWidget> m_ui;
}; };