Commit a1f60709 authored by Laurent Montel's avatar Laurent Montel 😁

Fix crash when we try to delete a wallet

parent 8c9edeaf
......@@ -372,6 +372,9 @@ void KWalletManager::createWallet()
void KWalletManager::deleteWallet()
{
QString walletName = _managerWidget->activeWalletName();
if (walletName.isEmpty()) {
return;
}
int rc = KMessageBox::warningContinueCancel(this, i18n("Are you sure you wish to delete the wallet '%1'?", walletName), QString(), KStandardGuiItem::del());
if (rc != KMessageBox::Continue) {
return;
......
......@@ -115,9 +115,14 @@ bool KWalletManagerWidget::openWallet(const QString &name)
return result;
}
const QString &KWalletManagerWidget::activeWalletName() const
QString KWalletManagerWidget::activeWalletName() const
{
return qobject_cast<KWalletManagerWidgetItem *>(currentPage())->walletName();
KWalletManagerWidgetItem *page = qobject_cast<KWalletManagerWidgetItem *>(currentPage());
if (page) {
return page->walletName();
} else {
return QString();
}
}
void KWalletManagerWidget::dragEnterEvent(QDragEnterEvent *e)
......@@ -202,7 +207,7 @@ bool KWalletManagerWidget::hasUnsavedChanges(const QString &name) const
if (name.isEmpty()) {
WalletPagesHash::const_iterator cp = _walletPages.constBegin();
WalletPagesHash::const_iterator cend = _walletPages.constEnd();
for (; cp != cend; cp++) {
for (; cp != cend; ++cp) {
if (cp.value()->hasUnsavedChanges()) {
return true;
}
......
......@@ -40,7 +40,7 @@ public:
bool openWalletFile(const QString &path);
bool openWallet(const QString &name);
const QString &activeWalletName() const;
QString activeWalletName() const;
bool hasUnsavedChanges(const QString& name) const;
protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment