mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 15:29:44 -05:00
FdoSecrets: fix crash when enabling the plugin on a non-exposed database
This commit is contained in:
parent
e2c95f75f1
commit
a66f8ec04d
@ -74,6 +74,10 @@ namespace FdoSecrets
|
||||
public:
|
||||
DBusReturn<void> setProperties(const QVariantMap& properties);
|
||||
|
||||
bool isValid() const {
|
||||
return backend();
|
||||
}
|
||||
|
||||
DBusReturn<void> removeAlias(QString alias);
|
||||
DBusReturn<void> addAlias(QString alias);
|
||||
const QSet<QString> aliases() const;
|
||||
@ -106,6 +110,7 @@ namespace FdoSecrets
|
||||
private slots:
|
||||
void onDatabaseLockChanged();
|
||||
void onDatabaseExposedGroupChanged();
|
||||
// force reload info from backend, potentially delete self
|
||||
void reloadBackend();
|
||||
|
||||
private:
|
||||
|
@ -93,7 +93,24 @@ namespace FdoSecrets
|
||||
|
||||
void Service::onDatabaseTabOpened(DatabaseWidget* dbWidget, bool emitSignal)
|
||||
{
|
||||
// The Collection will monitor the database's exposed group.
|
||||
// When the Collection finds that no exposed group, it will delete itself.
|
||||
// Thus the service also needs to monitor it and recreate the collection if the user changes
|
||||
// from no exposed to exposed something.
|
||||
if (!dbWidget->isLocked()) {
|
||||
monitorDatabaseExposedGroup(dbWidget);
|
||||
}
|
||||
connect(dbWidget, &DatabaseWidget::databaseUnlocked, this, [this, dbWidget]() {
|
||||
monitorDatabaseExposedGroup(dbWidget);
|
||||
});
|
||||
|
||||
auto coll = new Collection(this, dbWidget);
|
||||
// Creation may fail if the database is not exposed.
|
||||
// This is okay, because we monitor the expose settings above
|
||||
if (!coll->isValid()) {
|
||||
coll->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
m_collections << coll;
|
||||
m_dbToCollection[dbWidget] = coll;
|
||||
@ -127,15 +144,6 @@ namespace FdoSecrets
|
||||
emit collectionDeleted(coll);
|
||||
});
|
||||
|
||||
// a special case: the database changed from no expose to expose something.
|
||||
// in this case, there is no collection out there monitoring it, so create a new collection
|
||||
if (!dbWidget->isLocked()) {
|
||||
monitorDatabaseExposedGroup(dbWidget);
|
||||
}
|
||||
connect(dbWidget, &DatabaseWidget::databaseUnlocked, this, [this, dbWidget]() {
|
||||
monitorDatabaseExposedGroup(dbWidget);
|
||||
});
|
||||
|
||||
if (emitSignal) {
|
||||
emit collectionCreated(coll);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user