mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 00:39:53 -05:00
Store group references in Metadata as QPointer.
QPointer sets itself to 0 when the referenced object has been deleted. Refs #14
This commit is contained in:
parent
96146d9e80
commit
a3e7c93b59
@ -19,16 +19,12 @@
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/Group.h"
|
||||
|
||||
Metadata::Metadata(Database* parent)
|
||||
: QObject(parent)
|
||||
, m_parent(parent)
|
||||
{
|
||||
m_recycleBin = 0;
|
||||
m_entryTemplatesGroup = 0;
|
||||
m_lastSelectedGroup = 0;
|
||||
m_lastTopVisibleGroup = 0;
|
||||
|
||||
m_generator = "KeePassX";
|
||||
m_maintenanceHistoryDays = 365;
|
||||
m_recycleBinEnabled = true;
|
||||
@ -55,7 +51,8 @@ Metadata::Metadata(Database* parent)
|
||||
m_updateDatetime = true;
|
||||
}
|
||||
|
||||
template <class T> bool Metadata::set(T& property, const T& value) {
|
||||
template <class P, class V> bool Metadata::set(P& property, const V& value)
|
||||
{
|
||||
if (property != value) {
|
||||
property = value;
|
||||
Q_EMIT modified();
|
||||
@ -66,7 +63,7 @@ template <class T> bool Metadata::set(T& property, const T& value) {
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> bool Metadata::set(T& property, const T& value, QDateTime& dateTime) {
|
||||
template <class P, class V> bool Metadata::set(P& property, const V& value, QDateTime& dateTime) {
|
||||
if (property != value) {
|
||||
property = value;
|
||||
if (m_updateDatetime) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QImage>
|
||||
|
||||
@ -105,8 +106,8 @@ Q_SIGNALS:
|
||||
void modified();
|
||||
|
||||
private:
|
||||
template <class T> inline bool set(T& property, const T& value, QDateTime& dateTime);
|
||||
template <class T> inline bool set(T& property, const T& value);
|
||||
template <class P, class V> bool set(P& property, const V& value);
|
||||
template <class P, class V> bool set(P& property, const V& value, QDateTime& dateTime);
|
||||
|
||||
Database* m_parent;
|
||||
|
||||
@ -130,12 +131,12 @@ private:
|
||||
QHash<Uuid, QImage> m_customIcons;
|
||||
|
||||
bool m_recycleBinEnabled;
|
||||
Group* m_recycleBin;
|
||||
QPointer<Group> m_recycleBin;
|
||||
QDateTime m_recycleBinChanged;
|
||||
Group* m_entryTemplatesGroup;
|
||||
QPointer<Group> m_entryTemplatesGroup;
|
||||
QDateTime m_entryTemplatesGroupChanged;
|
||||
Group* m_lastSelectedGroup;
|
||||
Group* m_lastTopVisibleGroup;
|
||||
QPointer<Group> m_lastSelectedGroup;
|
||||
QPointer<Group> m_lastTopVisibleGroup;
|
||||
|
||||
QDateTime m_masterKeyChanged;
|
||||
int m_masterKeyChangeRec;
|
||||
|
Loading…
Reference in New Issue
Block a user