Commit 8dd0b02a authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Implement a cancelled() signal to fix cancellation of password dialogs

Implement a cancelled() signal in ReadOnlyArchiveInterface. This signal
is emitted in CliInterface when the user cancels a password dialog. The
signal is connected to a slot in Job which sets KJob::error to
KJob::KilledJobError.

The callers (Part and BatchExtract) are modified to do nothing if the
error code is KJob::KilledJobError when running ListJobs/ExtractJobs/
AddJobs/DeleteJobs. This fixes an issue where the user cancels the
"Enter password" dialog and the UI keeps being blocked and/or error
messageboxes appear.

BUG: 267670
FIXED-IN: 15.07.80
REVIEW: 123967
parent 7370acf3
......@@ -156,16 +156,17 @@ void BatchExtract::slotResult(KJob *job)
// TODO: The user must be informed about which file caused the error, and that the other files
// in the queue will not be extracted.
if (job->error()) {
qCDebug(ARK) << "There was en error, " << job->errorText();
qCDebug(ARK) << "There was en error:" << job->error() << ", errorText:" << job->errorText();
setErrorText(job->errorText());
setError(job->error());
removeSubjob(job);
KMessageBox::error(NULL, job->errorText().isEmpty() ?
i18n("There was an error during extraction.") : job->errorText()
);
if (job->error() != KJob::KilledJobError) {
KMessageBox::error(NULL, job->errorText().isEmpty() ?
i18n("There was an error during extraction.") : job->errorText());
}
emitResult();
......
......@@ -94,6 +94,7 @@ public:
virtual bool doResume();
signals:
void cancelled();
void error(const QString &message, const QString &details = QString());
void entry(const ArchiveEntry &archiveEntry);
void entryRemoved(const QString &path);
......
......@@ -164,6 +164,9 @@ bool CliInterface::copyFiles(const QList<QVariant> & files, const QString & dest
query.waitForResponse();
if (query.responseCancelled()) {
emit cancelled();
// There is no process running, so finished() must be emitted manually.
emit finished(false);
failOperation();
return false;
}
......@@ -525,6 +528,7 @@ void CliInterface::handleLine(const QString& line)
query.waitForResponse();
if (query.responseCancelled()) {
emit cancelled();
failOperation();
return;
}
......@@ -566,6 +570,7 @@ void CliInterface::handleLine(const QString& line)
query.waitForResponse();
if (query.responseCancelled()) {
emit cancelled();
failOperation();
return;
}
......
......@@ -115,6 +115,7 @@ void Job::emitResult()
void Job::connectToArchiveInterfaceSignals()
{
connect(archiveInterface(), SIGNAL(cancelled()), SLOT(onCancelled()));
connect(archiveInterface(), SIGNAL(error(QString,QString)), SLOT(onError(QString,QString)));
connect(archiveInterface(), SIGNAL(entry(ArchiveEntry)), SLOT(onEntry(ArchiveEntry)));
connect(archiveInterface(), SIGNAL(entryRemoved(QString)), SLOT(onEntryRemoved(QString)));
......@@ -124,11 +125,17 @@ void Job::connectToArchiveInterfaceSignals()
connect(archiveInterface(), SIGNAL(userQuery(Query*)), SLOT(onUserQuery(Query*)));
}
void Job::onCancelled()
{
qCDebug(KERFUFFLE) << "Cancelled emitted";
setError(KJob::KilledJobError);
}
void Job::onError(const QString & message, const QString & details)
{
Q_UNUSED(details)
setError(1);
setError(KJob::UserDefinedError);
setErrorText(message);
}
......
......@@ -67,6 +67,7 @@ public slots:
virtual void doWork() = 0;
protected slots:
virtual void onCancelled();
virtual void onError(const QString &message, const QString &details);
virtual void onInfo(const QString &info);
virtual void onEntry(const ArchiveEntry &archiveEntry);
......
......@@ -522,9 +522,13 @@ void Part::slotLoadingFinished(KJob *job)
{
if (job->error()) {
if (arguments().metaData()[QLatin1String( "createNewArchive" )] != QLatin1String( "true" )) {
KMessageBox::error(widget(), xi18nc("@info", "Loading the archive <filename>%1</filename> failed with the following error: <message>%2</message>",
localFilePath(), job->errorText()),
i18nc("@title:window", "Error Opening Archive"));
if (job->error() != KJob::KilledJobError) {
KMessageBox::error(widget(),
xi18nc("@info", "Loading the archive <filename>%1</filename> failed with the following error: <message>%2</message>",
localFilePath(),
job->errorText()),
i18nc("@title:window", "Error Opening Archive"));
}
// The file failed to open, so reset the open archive, info panel and caption.
m_model->setArchive(Q_NULLPTR);
......@@ -641,7 +645,7 @@ void Part::slotPreviewExtracted(KJob *job)
KRun::displayOpenWithDialog(list, widget(), true);
break;
}
} else {
} else if (job->error() != KJob::KilledJobError) {
KMessageBox::error(widget(), job->errorString());
}
setReadyGui();
......@@ -773,7 +777,7 @@ QList<QVariant> Part::selectedFiles() const
void Part::slotExtractionDone(KJob* job)
{
if (job->error()) {
if (job->error() && job->error() != KJob::KilledJobError) {
KMessageBox::error(widget(), job->errorString());
} else {
ExtractJob *extractJob = qobject_cast<ExtractJob*>(job);
......@@ -873,14 +877,14 @@ void Part::slotAddDir()
void Part::slotAddFilesDone(KJob* job)
{
if (job->error()) {
if (job->error() && job->error() != KJob::KilledJobError) {
KMessageBox::error(widget(), job->errorString());
}
}
void Part::slotDeleteFilesDone(KJob* job)
{
if (job->error()) {
if (job->error() && job->error() != KJob::KilledJobError) {
KMessageBox::error(widget(), job->errorString());
}
}
......
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