|
35 | 35 | #include <QUrl> |
36 | 36 | #include <application.hpp> |
37 | 37 |
|
38 | | -#define CATCH_AND_EMIT_FAILURE_AND_RETURN() \ |
39 | | - catch (std::exception & e) \ |
40 | | - { \ |
41 | | - emit failure(e.what()); \ |
42 | | - return; \ |
43 | | - } |
44 | | - |
45 | 38 | using namespace electronic_id; |
46 | 39 |
|
47 | 40 | class WebEidDialog::Private : public Ui::WebEidDialog |
@@ -133,16 +126,20 @@ void WebEidDialog::showAboutPage() |
133 | 126 |
|
134 | 127 | void WebEidDialog::showFatalErrorPage() |
135 | 128 | { |
136 | | - ui->messagePageTitleLabel->setText(tr("Operation failed")); |
137 | | - ui->fatalError->show(); |
138 | | - ui->fatalHelp->show(); |
139 | | - ui->connectCardLabel->hide(); |
140 | | - ui->cardChipIcon->hide(); |
141 | | - ui->helpButton->show(); |
142 | | - ui->cancelButton->show(); |
143 | | - ui->okButton->hide(); |
144 | | - ui->pageStack->setCurrentIndex(int(Page::ALERT)); |
145 | | - exec(); |
| 129 | + WebEidDialog* d = new WebEidDialog(); |
| 130 | + d->setAttribute(Qt::WA_DeleteOnClose); |
| 131 | + d->ui->messagePageTitleLabel->setText(tr("Operation failed")); |
| 132 | + d->ui->fatalError->show(); |
| 133 | + d->ui->fatalHelp->show(); |
| 134 | + d->ui->connectCardLabel->hide(); |
| 135 | + d->ui->cardChipIcon->hide(); |
| 136 | + d->ui->helpButton->show(); |
| 137 | + d->ui->cancelButton->show(); |
| 138 | + d->ui->okButton->hide(); |
| 139 | + d->ui->pageStack->setCurrentIndex(int(Page::ALERT)); |
| 140 | + d->adjustSize(); |
| 141 | + d->open(); |
| 142 | + connect(d, &WebEidDialog::finished, qApp, &QApplication::quit); |
146 | 143 | } |
147 | 144 |
|
148 | 145 | void WebEidDialog::showWaitingForCardPage(const CommandType commandType) |
@@ -193,29 +190,21 @@ void WebEidDialog::onMultipleCertificatesReady( |
193 | 190 |
|
194 | 191 | if (CertificateButton* button = |
195 | 192 | qobject_cast<CertificateButton*>(ui->selectionGroup->checkedButton())) { |
196 | | - try { |
197 | | - switch (currentCommand) { |
198 | | - case CommandType::GET_SIGNING_CERTIFICATE: |
199 | | - setupOK([this, button] { emit accepted(button->certificateInfo()); }); |
200 | | - break; |
201 | | - case CommandType::AUTHENTICATE: |
202 | | - // Authenticate continues with the selected certificate to |
203 | | - // onSingleCertificateReady(). |
204 | | - setupOK([this, origin, button] { |
205 | | - try { |
206 | | - onSingleCertificateReady(origin, button->certificateInfo()); |
207 | | - } |
208 | | - CATCH_AND_EMIT_FAILURE_AND_RETURN() |
209 | | - }); |
210 | | - break; |
211 | | - default: |
212 | | - THROW(ProgrammingError, |
213 | | - "Command " + std::string(currentCommand) + " not allowed here"); |
214 | | - } |
215 | 193 |
|
| 194 | + switch (currentCommand) { |
| 195 | + case CommandType::GET_SIGNING_CERTIFICATE: |
| 196 | + setupOK([this, button] { emit accepted(button->certificateInfo()); }); |
216 | 197 | ui->pageStack->setCurrentIndex(int(Page::SELECT_CERTIFICATE)); |
| 198 | + break; |
| 199 | + case CommandType::AUTHENTICATE: |
| 200 | + // Authenticate continues with the selected certificate to onSingleCertificateReady(). |
| 201 | + onSingleCertificateReady(origin, button->certificateInfo()); |
| 202 | + break; |
| 203 | + default: |
| 204 | + emit failure(QStringLiteral("Command %1 not allowed here") |
| 205 | + .arg(std::string(currentCommand).c_str())); |
| 206 | + return; |
217 | 207 | } |
218 | | - CATCH_AND_EMIT_FAILURE_AND_RETURN() |
219 | 208 | } else { |
220 | 209 | emit failure(QStringLiteral("CertificateButton not found")); |
221 | 210 | } |
@@ -279,8 +268,10 @@ void WebEidDialog::onSingleCertificateReady(const QUrl& origin, |
279 | 268 | } |
280 | 269 |
|
281 | 270 | ui->pageStack->setCurrentIndex(int(WebEidDialog::Page::PIN_INPUT)); |
| 271 | + } catch (std::exception& e) { |
| 272 | + emit failure(e.what()); |
| 273 | + return; |
282 | 274 | } |
283 | | - CATCH_AND_EMIT_FAILURE_AND_RETURN() |
284 | 275 | } |
285 | 276 |
|
286 | 277 | void WebEidDialog::onRetry(const RetriableError error) |
|
0 commit comments