If a rename job started from View Mode fails, no warning message is
shown. This is caused by the default disabled AutoErrorHandling in
KJobUiDelegate.
This patch enables the flag after creating the job.
BUG: 395890
FIXED-IN: 18.04.3
rkflx |
Gwenview |
If a rename job started from View Mode fails, no warning message is
shown. This is caused by the default disabled AutoErrorHandling in
KJobUiDelegate.
This patch enables the flag after creating the job.
BUG: 395890
FIXED-IN: 18.04.3
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
An extended error message (e.g. with Overwrite option) for Browse Mode needs a bit of rework, since the renaming is done by the model (not Gwenview) here.
app/fileoperations.cpp | ||
---|---|---|
249 | Calling showErrorMessage() outside a result slot is not recommended and not needed anymore. |
Thanks, LGTM.
I also added some comments to https://bugs.kde.org/show_bug.cgi?id=395890#c4. Keep in mind I did not know yet about your Diff when I wrote them, but apparently you came up with the same fix ;) I'd say let's land your patch to stable, and we can see about further improvements in master.
The only thing I'm not sure about is showErrorMessage(): Why did it work in KDE 4, but does not work anymore? Your new code is fine, but maybe we also have a problem in KF5, which obviously we should try to fix (or we might run into it again and again… – e.g. did you check GVPart::showJobError?).
I think it just works like stated in the api docu now and the previous use was incorrect (but worked nevertheless). Calling showErrorMessage() from inside a result slot is ok and the error message shows up, e.g. using this code instead of enabling AutoErrorHandling works too:
KIO::SimpleJob* job = KIO::rename(oldUrl, newUrl, KIO::HideProgressInfo); QObject::connect(job, &KJob::result, [=](KJob* job) { job->uiDelegate()->showErrorMessage(); });
(GVPart::saveAs() / GVPart::showJobError should work fine but no idea how to test this.)
Okay, at least it's still working in that case. Thanks for the sample code ;)
The following change in R288 KJobWidgets makes it work for me, so this seems to be related to event handling:
@@ -102,7 +104,7 @@ void KDialogJobUiDelegate::Private::queuedMessageBox(QWidget *widget, KMessageBo if (!running) { running = true; - QMetaObject::invokeMethod(this, "next", Qt::QueuedConnection); + next(); } }
Looks like some of the porting work to KF5 caused this: efbf655b7ab5. Anyway, probably better to keep this as is.
(GVPart::saveAs() / GVPart::showJobError should work fine but no idea how to test this.)
You are right, I could now confirm it works fine: Using Gwenview's KPart, Save As in Konqueror to a read-only directory and compare w/ and w/o the call to showErrorMessage (the rename case is already caught by the file dialog).
BTW, this also works:
job->uiDelegate()->showErrorMessage(); qApp->processEvents();
(Might be useful in cases where setAutoErrorHandlingEnabled(true) is inappropriate.)