Bug 494500 - Catalog::altTrans() / m_storage sometimes filled with repeat entry
Summary: Catalog::altTrans() / m_storage sometimes filled with repeat entry
Status: RESOLVED FIXED
Alias: None
Product: lokalize
Classification: Applications
Component: translation memory (other bugs)
Version First Reported In: 24.08.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Simon Depiets
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-11 04:51 UTC by Finley Watson
Modified: 2025-01-02 23:00 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Finley Watson 2024-10-11 04:51:08 UTC
SUMMARY
Typically the Alternative Translations window shows 1 or sometimes 2 entries. When the entry shown is from the alternative translation file (e.g. a different language entry to the current translation language), the option to enter the ATM entry text is shown as Alt+1 etc. but sometimes the CatalogStorage m_storage provided by catalog.h has an entry already and then in catalop.cpp Catalog::altTrans() a seemingly identical entry is added. This is happening with .po files, and causes the entry in the ATM to display with the keyboard shortcut Alt+2 even though it's the first entry, because the shortcut number is generated based on the current loop in alttransview.cpp AltTransView::process() and the first entry was skipped.

STEPS TO REPRODUCE
1. Set up alternative translations file in project settings.
2. Open a file with related entries from the alternative translations file.
Comment 1 Finley Watson 2024-12-28 00:26:36 UTC
This also causes problems for the alttransview.cpp AltTransView::process() logic, not just for displaying entries, because the function should exit early if there are no entries.

The empty initial entry is added to m_storage in catalog.cpp Catalog::altTrans() because that function returns a QVector<AltTrans>, and the first entry (typically? always?) has empty source and target strings because of this code, where the altTrans() contains an entry that has empty source and target strings:
    if (m_storage)
        result = m_storage->altTrans(pos);
Comment 2 Bug Janitor Service 2024-12-28 13:57:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/lokalize/-/merge_requests/192
Comment 3 Finley Watson 2024-12-28 18:13:10 UTC
Git commit 64903c06c65e8bbdd9a27ea50ba03c1c5183b731 by Finley Watson.
Committed on 28/12/2024 at 14:21.
Pushed by jjazeix into branch 'master'.

Do not return QVector with an empty AltTrans
Only return a QVector containing data when data actually exists for at
least one field of the AltTrans struct.

M  +6    -3    src/catalog/gettext/gettextstorage.cpp

https://invent.kde.org/sdk/lokalize/-/commit/64903c06c65e8bbdd9a27ea50ba03c1c5183b731
Comment 4 Albert Astals Cid 2025-01-02 23:00:31 UTC
Git commit b79e41273df1360bb11fa94dc953c6cf8b25bbff by Albert Astals Cid, on behalf of Finley Watson.
Committed on 02/01/2025 at 22:58.
Pushed by aacid into branch 'release/24.12'.

Do not return QVector with an empty AltTrans

Only return a QVector containing data when data actually exists for at
least one field of the AltTrans struct.
(cherry picked from commit 64903c06c65e8bbdd9a27ea50ba03c1c5183b731)

M  +6    -3    src/catalog/gettext/gettextstorage.cpp

https://invent.kde.org/sdk/lokalize/-/commit/b79e41273df1360bb11fa94dc953c6cf8b25bbff