Bug 416427

Summary: TM doesn't work due to: requested database does not belong to the calling thread
Product: [Applications] lokalize Reporter: Robert Kratky <kratky>
Component: translation memoryAssignee: Simon Depiets <sdepiets>
Status: RESOLVED FIXED    
Severity: normal CC: shafff, valtermura
Priority: NOR    
Version: 19.12   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Robert Kratky 2020-01-18 17:18:39 UTC
SUMMARY

The TM doesn't work.

* Existing TM cannot be browsed or used for suggestions
* New TM cannot be built.

STEPS TO REPRODUCE
1. Perform any TM-related operation

OBSERVED RESULT
* Nothing happens
* Terminal output:

QSqlDatabasePrivate::database: requested database does not belong to the calling thread.

EXPECTED RESULT
TM works normally.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 31
(available in About System)
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.64.0
Qt Version: 5.13.2

ADDITIONAL INFORMATION

I found a related Qt bug, which was supposed to be fixed in 5.13: https://bugreports.qt.io/browse/QTBUG-72545

The issue started to appear about a year ago, but then there was a period when it worked again. Unfortunately, I didn't file the bug then and didn't even make a note of the lokalize and Qt versions.
Comment 1 Valter Mura 2020-05-02 18:09:41 UTC
I have a similar problem: I have 3 TMs created some years ago but now they neither  auto-update when I translate, nor update when I try to add translated files manually.

Operating System: KDE neon Testing Edition
KDE Plasma Version: 5.18.4
KDE Frameworks Version: 5.70.0
Qt Version: 5.14.2
Kernel Version: 5.3.0-51-generic
OS Type: 64-bit
Comment 2 Simon Depiets 2020-05-03 14:24:13 UTC
I've seen this error in the past but I've never seen any side effects, would you be able to post your TM somewhere so I can have a look? It's in ~/.local/share/lokalize
After that, would it be possible for you to regenerate your TM and see if there's still an issue?
Comment 3 Valter Mura 2020-05-03 17:46:15 UTC
(In reply to Simon Depiets from comment #2)
> I've seen this error in the past but I've never seen any side effects, would
> you be able to post your TM somewhere so I can have a look? It's in
> ~/.local/share/lokalize
> After that, would it be possible for you to regenerate your TM and see if
> there's still an issue?

Hi, for me it's currently solved, using these steps:

- close the project with the TM not working
- delete the TM from ~/.local/share/lokalize
- reopen the project and open file already translated and file to translate

Now the TM adds and suggests correctly, and the pairs' count increases normally.
Comment 4 Simon Depiets 2020-06-14 03:19:12 UTC
Git commit 8ce6b3d89598b6bc7570d11e7063b08394b3c0c9 by Simon Depiets.
Committed on 14/06/2020 at 03:16.
Pushed by sdepiets into branch 'master'.

Use thread specific names for connection Names

There seems to have been two issues with TM connections.
The first was that the TM connection was closed on project change (while they are actually all opened for stats purposes).
The second was that the connection names where not thread specific, which could cause issues, and it will now be the case.
Related: bug 422251

M  +4    -2    src/project/project.cpp
M  +41   -27   src/tm/jobs.cpp

https://invent.kde.org/sdk/lokalize/commit/8ce6b3d89598b6bc7570d11e7063b08394b3c0c9
Comment 5 Simon Depiets 2020-06-14 03:21:13 UTC
I have made some changes in the handling of TM connections, could you build from master and give it a try ?