this, &ProxyAuthHandler::slotSenderDestroyed);
}
}
-
-void ProxyAuthHandler::slotKeychainJobDone()
-{
- _keychainJobRunning = false;
-}
-
+
void ProxyAuthHandler::slotSenderDestroyed(QObject *obj)
{
_gaveCredentialsTo.remove(obj);
bool ProxyAuthHandler::getCredsFromDialog()
{
+ QEventLoop waitLoop;
+
// Open the credentials dialog
if (!_waitingForDialog) {
_dialog->reset();
_dialog->setProxyAddress(_proxy);
+ connect(_dialog, &QDialog::finished, &waitLoop, &QEventLoop::quit);
_dialog->open();
}
// If that's the case, continue processing the dialog until
// it's done.
++_waitingForDialog;
- while (_dialog && _dialog->isVisible()) {
- QApplication::processEvents(QEventLoop::ExcludeSocketNotifiers, 200);
+ if (_dialog) {
+ waitLoop.exec(QEventLoop::ExcludeSocketNotifiers);
}
--_waitingForDialog;
bool ProxyAuthHandler::getCredsFromKeychain()
{
using namespace QKeychain;
+ QEventLoop waitLoop;
if (_waitingForDialog) {
return false;
_readPasswordJob->setInsecureFallback(false);
_readPasswordJob->setKey(keychainPasswordKey());
_readPasswordJob->setAutoDelete(false);
- connect(_readPasswordJob.data(), &QKeychain::Job::finished,
- this, &ProxyAuthHandler::slotKeychainJobDone);
- _keychainJobRunning = true;
+ connect(_readPasswordJob.data(), &QKeychain::Job::finished, &waitLoop, &QEventLoop::quit);
_readPasswordJob->start();
}
// bad behavior when we reenter this code after the flag has been switched
// but before the while loop has finished.
++_waitingForKeychain;
- _keychainJobRunning = true;
- while (_keychainJobRunning) {
- QApplication::processEvents(QEventLoop::AllEvents, 200);
- }
+ waitLoop.exec();
--_waitingForKeychain;
if (_readPasswordJob->error() == NoError) {
void ProxyAuthHandler::storeCredsInKeychain()
{
using namespace QKeychain;
+ QEventLoop waitLoop;
if (_waitingForKeychain) {
return;
job->setKey(keychainPasswordKey());
job->setTextData(_password);
job->setAutoDelete(false);
- connect(job, &QKeychain::Job::finished, this, &ProxyAuthHandler::slotKeychainJobDone);
- _keychainJobRunning = true;
+ connect(job, &QKeychain::Job::finished, &waitLoop, &QEventLoop::quit);
job->start();
++_waitingForKeychain;
- _keychainJobRunning = true;
- while (_keychainJobRunning) {
- QApplication::processEvents(QEventLoop::AllEvents, 200);
- }
+ waitLoop.exec();
--_waitingForKeychain;
job->deleteLater();