Delete translation memory “meta” scan jobs when switching projects
ClosedPublic

Authored by adrianchavesfernandez on Sun, Aug 18, 7:29 PM.

Details

Summary

When you start an operation to add files to the translation memory of the current project, a “meta” job is created and registered in the system with KIO, so that there is a system-wide progress report.

When you switch to a different project before the process finishes, however, the process stops (as in stops progressing) but the notification continues, and needs to be manually stopped by the user.

The reason is that on project switch we are cancelling all the jobs that perform the actual scanning, but we are leaving the parent job responsible for reporting the total progress in memory.

The proposed changes aim to fix that.

I must say however that I do not consider myself a C++/Qt programmer, but rather a Python programmer. So please pay close attention to the code, in case I’m doing something silly. I’m also completely open to any kind of style feedback, including variable naming.

BUG: 293790

Test Plan

Tested manually.

Diff Detail

Repository
R456 Lokalize
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
adrianchavesfernandez requested review of this revision.Sun, Aug 18, 7:29 PM
adrianchavesfernandez created this revision.
adrianchavesfernandez edited the summary of this revision. (Show Details)Sun, Aug 18, 7:32 PM
adrianchavesfernandez retitled this revision from Delete translation memory “meta” scan jobs when switching projects to [WIP] Delete translation memory “meta” scan jobs when switching projects.Wed, Aug 21, 9:46 PM

Had a talk with @aacid regarding a more elegant implementation. I’ll post a new version of the patch in a few days.

Updated with a cleaner approach based on feedback from @aacid.

adrianchavesfernandez retitled this revision from [WIP] Delete translation memory “meta” scan jobs when switching projects to Delete translation memory “meta” scan jobs when switching projects.Sat, Aug 24, 10:14 AM

We can probably remove this too?

if (processedAmount(KJob::Files) == totalAmount(KJob::Files)) {
    emitResult();
    qCDebug(LOKALIZE_LOG) << "finished in" << m_time.elapsed() << "msecs";
}

Otherwise we're emitting result twice when not cancelling, aren't we?

adrianchavesfernandez retitled this revision from Delete translation memory “meta” scan jobs when switching projects to [WIP] Delete translation memory “meta” scan jobs when switching projects.Sat, Aug 24, 10:35 AM

Indeed.

adrianchavesfernandez retitled this revision from [WIP] Delete translation memory “meta” scan jobs when switching projects to Delete translation memory “meta” scan jobs when switching projects.

Done.

aacid accepted this revision.Sat, Aug 24, 4:20 PM
This revision is now accepted and ready to land.Sat, Aug 24, 4:20 PM
This revision was automatically updated to reflect the committed changes.