mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Avoid copying QSharedPointers when not needed
This commit is contained in:
parent
6df9c6f9b2
commit
39b96c13e8
@ -348,7 +348,7 @@ void BrowserService::addEntry(const QString& id,
|
|||||||
const QString& realm,
|
const QString& realm,
|
||||||
const QString& group,
|
const QString& group,
|
||||||
const QString& groupUuid,
|
const QString& groupUuid,
|
||||||
QSharedPointer<Database> selectedDb)
|
const QSharedPointer<Database>& selectedDb)
|
||||||
{
|
{
|
||||||
if (thread() != QThread::currentThread()) {
|
if (thread() != QThread::currentThread()) {
|
||||||
QMetaObject::invokeMethod(this,
|
QMetaObject::invokeMethod(this,
|
||||||
@ -482,7 +482,7 @@ void BrowserService::updateEntry(const QString& id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Entry*> BrowserService::searchEntries(QSharedPointer<Database> db, const QString& hostname, const QString& url)
|
QList<Entry*> BrowserService::searchEntries(const QSharedPointer<Database>& db, const QString& hostname, const QString& url)
|
||||||
{
|
{
|
||||||
QList<Entry*> entries;
|
QList<Entry*> entries;
|
||||||
auto* rootGroup = db->rootGroup();
|
auto* rootGroup = db->rootGroup();
|
||||||
@ -549,7 +549,7 @@ QList<Entry*> BrowserService::searchEntries(const QString& url, const StringPair
|
|||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserService::convertAttributesToCustomData(QSharedPointer<Database> currentDb)
|
void BrowserService::convertAttributesToCustomData(const QSharedPointer<Database>& currentDb)
|
||||||
{
|
{
|
||||||
auto db = currentDb ? currentDb : getDatabase();
|
auto db = currentDb ? currentDb : getDatabase();
|
||||||
if (!db) {
|
if (!db) {
|
||||||
@ -770,7 +770,7 @@ BrowserService::checkAccess(const Entry* entry, const QString& host, const QStri
|
|||||||
return Unknown;
|
return Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
Group* BrowserService::findCreateAddEntryGroup(QSharedPointer<Database> selectedDb)
|
Group* BrowserService::findCreateAddEntryGroup(const QSharedPointer<Database>& selectedDb)
|
||||||
{
|
{
|
||||||
auto db = selectedDb ? selectedDb : getDatabase();
|
auto db = selectedDb ? selectedDb : getDatabase();
|
||||||
if (!db) {
|
if (!db) {
|
||||||
@ -955,7 +955,7 @@ bool BrowserService::moveSettingsToCustomData(Entry* entry, const QString& name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BrowserService::moveKeysToCustomData(Entry* entry, QSharedPointer<Database> db) const
|
int BrowserService::moveKeysToCustomData(Entry* entry, const QSharedPointer<Database>& db) const
|
||||||
{
|
{
|
||||||
int keyCounter = 0;
|
int keyCounter = 0;
|
||||||
for (const auto& key : entry->attributes()->keys()) {
|
for (const auto& key : entry->attributes()->keys()) {
|
||||||
|
@ -54,10 +54,10 @@ public:
|
|||||||
const QString& realm,
|
const QString& realm,
|
||||||
const QString& group,
|
const QString& group,
|
||||||
const QString& groupUuid,
|
const QString& groupUuid,
|
||||||
QSharedPointer<Database> selectedDb = {});
|
const QSharedPointer<Database>& selectedDb = {});
|
||||||
QList<Entry*> searchEntries(QSharedPointer<Database> db, const QString& hostname, const QString& url);
|
QList<Entry*> searchEntries(const QSharedPointer<Database>& db, const QString& hostname, const QString& url);
|
||||||
QList<Entry*> searchEntries(const QString& url, const StringPairList& keyList);
|
QList<Entry*> searchEntries(const QString& url, const StringPairList& keyList);
|
||||||
void convertAttributesToCustomData(QSharedPointer<Database> currentDb = {});
|
void convertAttributesToCustomData(const QSharedPointer<Database>& currentDb = {});
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const char KEEPASSXCBROWSER_NAME[];
|
static const char KEEPASSXCBROWSER_NAME[];
|
||||||
@ -106,7 +106,7 @@ private:
|
|||||||
const QString& realm);
|
const QString& realm);
|
||||||
QJsonObject prepareEntry(const Entry* entry);
|
QJsonObject prepareEntry(const Entry* entry);
|
||||||
Access checkAccess(const Entry* entry, const QString& host, const QString& submitHost, const QString& realm);
|
Access checkAccess(const Entry* entry, const QString& host, const QString& submitHost, const QString& realm);
|
||||||
Group* findCreateAddEntryGroup(QSharedPointer<Database> selectedDb = {});
|
Group* findCreateAddEntryGroup(const QSharedPointer<Database>& selectedDb = {});
|
||||||
int
|
int
|
||||||
sortPriority(const Entry* entry, const QString& host, const QString& submitUrl, const QString& baseSubmitUrl) const;
|
sortPriority(const Entry* entry, const QString& host, const QString& submitUrl, const QString& baseSubmitUrl) const;
|
||||||
bool matchUrlScheme(const QString& url);
|
bool matchUrlScheme(const QString& url);
|
||||||
@ -116,7 +116,7 @@ private:
|
|||||||
QSharedPointer<Database> selectedDatabase();
|
QSharedPointer<Database> selectedDatabase();
|
||||||
QJsonArray addChildrenToGroup(Group* group);
|
QJsonArray addChildrenToGroup(Group* group);
|
||||||
bool moveSettingsToCustomData(Entry* entry, const QString& name) const;
|
bool moveSettingsToCustomData(Entry* entry, const QString& name) const;
|
||||||
int moveKeysToCustomData(Entry* entry, QSharedPointer<Database> db) const;
|
int moveKeysToCustomData(Entry* entry, const QSharedPointer<Database>& db) const;
|
||||||
bool checkLegacySettings();
|
bool checkLegacySettings();
|
||||||
void hideWindow() const;
|
void hideWindow() const;
|
||||||
void raiseWindow(const bool force = false);
|
void raiseWindow(const bool force = false);
|
||||||
|
@ -77,7 +77,7 @@ int Clip::execute(const QStringList& arguments)
|
|||||||
return clipEntry(db, args.at(1), args.value(2), parser.isSet(totp), parser.isSet(Command::QuietOption));
|
return clipEntry(db, args.at(1), args.value(2), parser.isSet(totp), parser.isSet(Command::QuietOption));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Clip::clipEntry(QSharedPointer<Database> database,
|
int Clip::clipEntry(const QSharedPointer<Database>& database,
|
||||||
const QString& entryPath,
|
const QString& entryPath,
|
||||||
const QString& timeout,
|
const QString& timeout,
|
||||||
bool clipTotp,
|
bool clipTotp,
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
Clip();
|
Clip();
|
||||||
~Clip();
|
~Clip();
|
||||||
int execute(const QStringList& arguments) override;
|
int execute(const QStringList& arguments) override;
|
||||||
int clipEntry(QSharedPointer<Database> database,
|
int clipEntry(const QSharedPointer<Database>& database,
|
||||||
const QString& entryPath,
|
const QString& entryPath,
|
||||||
const QString& timeout,
|
const QString& timeout,
|
||||||
bool clipTotp,
|
bool clipTotp,
|
||||||
|
@ -74,7 +74,7 @@ int Create::execute(const QStringList& arguments)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString databaseFilename = args.at(0);
|
const QString& databaseFilename = args.at(0);
|
||||||
if (QFileInfo::exists(databaseFilename)) {
|
if (QFileInfo::exists(databaseFilename)) {
|
||||||
err << QObject::tr("File %1 already exists.").arg(databaseFilename) << endl;
|
err << QObject::tr("File %1 already exists.").arg(databaseFilename) << endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -150,7 +150,7 @@ QSharedPointer<PasswordKey> Create::getPasswordFromStdin()
|
|||||||
* @param fileKey Resulting fileKey
|
* @param fileKey Resulting fileKey
|
||||||
* @return true if the key file was loaded succesfully
|
* @return true if the key file was loaded succesfully
|
||||||
*/
|
*/
|
||||||
bool Create::loadFileKey(QString path, QSharedPointer<FileKey>& fileKey)
|
bool Create::loadFileKey(const QString& path, QSharedPointer<FileKey>& fileKey)
|
||||||
{
|
{
|
||||||
QTextStream err(Utils::STDERR, QIODevice::WriteOnly);
|
QTextStream err(Utils::STDERR, QIODevice::WriteOnly);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QSharedPointer<PasswordKey> getPasswordFromStdin();
|
QSharedPointer<PasswordKey> getPasswordFromStdin();
|
||||||
QSharedPointer<FileKey> getFileKeyFromStdin();
|
QSharedPointer<FileKey> getFileKeyFromStdin();
|
||||||
bool loadFileKey(QString path, QSharedPointer<FileKey>& fileKey);
|
bool loadFileKey(const QString& path, QSharedPointer<FileKey>& fileKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSXC_CREATE_H
|
#endif // KEEPASSXC_CREATE_H
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
|
|
||||||
bool CsvExporter::exportDatabase(const QString& filename, QSharedPointer<const Database> db)
|
bool CsvExporter::exportDatabase(const QString& filename, const QSharedPointer<const Database>& db)
|
||||||
{
|
{
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
@ -33,7 +33,7 @@ bool CsvExporter::exportDatabase(const QString& filename, QSharedPointer<const D
|
|||||||
return exportDatabase(&file, db);
|
return exportDatabase(&file, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsvExporter::exportDatabase(QIODevice* device, QSharedPointer<const Database> db)
|
bool CsvExporter::exportDatabase(QIODevice* device, const QSharedPointer<const Database>& db)
|
||||||
{
|
{
|
||||||
QString header;
|
QString header;
|
||||||
addColumn(header, "Group");
|
addColumn(header, "Group");
|
||||||
|
@ -29,8 +29,8 @@ class QIODevice;
|
|||||||
class CsvExporter
|
class CsvExporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool exportDatabase(const QString& filename, QSharedPointer<const Database> db);
|
bool exportDatabase(const QString& filename, const QSharedPointer<const Database>& db);
|
||||||
bool exportDatabase(QIODevice* device, QSharedPointer<const Database> db);
|
bool exportDatabase(QIODevice* device, const QSharedPointer<const Database>& db);
|
||||||
QString errorString() const;
|
QString errorString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -113,7 +113,7 @@ void EditWidgetIcons::reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditWidgetIcons::load(const QUuid& currentUuid,
|
void EditWidgetIcons::load(const QUuid& currentUuid,
|
||||||
QSharedPointer<Database> database,
|
const QSharedPointer<Database>& database,
|
||||||
const IconStruct& iconStruct,
|
const IconStruct& iconStruct,
|
||||||
const QString& url)
|
const QString& url)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
IconStruct state();
|
IconStruct state();
|
||||||
void reset();
|
void reset();
|
||||||
void load(const QUuid& currentUuid,
|
void load(const QUuid& currentUuid,
|
||||||
QSharedPointer<Database> database,
|
const QSharedPointer<Database>& database,
|
||||||
const IconStruct& iconStruct,
|
const IconStruct& iconStruct,
|
||||||
const QString& url = "");
|
const QString& url = "");
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ DatabaseSettingsDialog::~DatabaseSettingsDialog()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseSettingsDialog::load(QSharedPointer<Database> db)
|
void DatabaseSettingsDialog::load(const QSharedPointer<Database>& db)
|
||||||
{
|
{
|
||||||
m_ui->categoryList->setCurrentCategory(0);
|
m_ui->categoryList->setCurrentCategory(0);
|
||||||
m_generalWidget->load(db);
|
m_generalWidget->load(db);
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
~DatabaseSettingsDialog() override;
|
~DatabaseSettingsDialog() override;
|
||||||
Q_DISABLE_COPY(DatabaseSettingsDialog);
|
Q_DISABLE_COPY(DatabaseSettingsDialog);
|
||||||
|
|
||||||
void load(QSharedPointer<Database> db);
|
void load(const QSharedPointer<Database>& db);
|
||||||
void addSettingsPage(IDatabaseSettingsPage* page);
|
void addSettingsPage(IDatabaseSettingsPage* page);
|
||||||
void showMasterKeySettings();
|
void showMasterKeySettings();
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include "DatabaseSettingsWidget.h"
|
#include "DatabaseSettingsWidget.h"
|
||||||
#include "core/Database.h"
|
#include "core/Database.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@ -38,6 +40,6 @@ DatabaseSettingsWidget::~DatabaseSettingsWidget()
|
|||||||
*/
|
*/
|
||||||
void DatabaseSettingsWidget::load(QSharedPointer<Database> db)
|
void DatabaseSettingsWidget::load(QSharedPointer<Database> db)
|
||||||
{
|
{
|
||||||
m_db = db;
|
m_db = std::move(db);
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ EditGroupWidget::~EditGroupWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditGroupWidget::loadGroup(Group* group, bool create, QSharedPointer<Database> database)
|
void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer<Database>& database)
|
||||||
{
|
{
|
||||||
m_group = group;
|
m_group = group;
|
||||||
m_db = database;
|
m_db = database;
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
explicit EditGroupWidget(QWidget* parent = nullptr);
|
explicit EditGroupWidget(QWidget* parent = nullptr);
|
||||||
~EditGroupWidget();
|
~EditGroupWidget();
|
||||||
|
|
||||||
void loadGroup(Group* group, bool create, QSharedPointer<Database> database);
|
void loadGroup(Group* group, bool create, const QSharedPointer<Database>& database);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void addEditPage(IEditGroupPage* page);
|
void addEditPage(IEditGroupPage* page);
|
||||||
|
@ -50,7 +50,7 @@ GroupView::GroupView(Database* db, QWidget* parent)
|
|||||||
setDefaultDropAction(Qt::MoveAction);
|
setDefaultDropAction(Qt::MoveAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupView::changeDatabase(QSharedPointer<Database> newDb)
|
void GroupView::changeDatabase(const QSharedPointer<Database>& newDb)
|
||||||
{
|
{
|
||||||
m_model->changeDatabase(newDb.data());
|
m_model->changeDatabase(newDb.data());
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class GroupView : public QTreeView
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GroupView(Database* db, QWidget* parent = nullptr);
|
explicit GroupView(Database* db, QWidget* parent = nullptr);
|
||||||
void changeDatabase(QSharedPointer<Database> newDb);
|
void changeDatabase(const QSharedPointer<Database>& newDb);
|
||||||
void setModel(QAbstractItemModel* model) override;
|
void setModel(QAbstractItemModel* model) override;
|
||||||
Group* currentGroup();
|
Group* currentGroup();
|
||||||
void setCurrentGroup(Group* group);
|
void setCurrentGroup(Group* group);
|
||||||
|
@ -38,7 +38,7 @@ class NewDatabaseWizardPage : public QWizardPage
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NewDatabaseWizardPage(QWidget* parent = nullptr);
|
explicit NewDatabaseWizardPage(QWidget* parent = nullptr);
|
||||||
Q_DISABLE_COPY(NewDatabaseWizardPage);
|
Q_DISABLE_COPY(NewDatabaseWizardPage)
|
||||||
~NewDatabaseWizardPage() override;
|
~NewDatabaseWizardPage() override;
|
||||||
|
|
||||||
void setPageWidget(DatabaseSettingsWidget* page);
|
void setPageWidget(DatabaseSettingsWidget* page);
|
||||||
|
Loading…
Reference in New Issue
Block a user