Merge lp:~laney/ubuntu-system-settings/fix-translated-search into lp:ubuntu-system-settings

Proposed by Iain Lane
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 493
Merged at revision: 495
Proposed branch: lp:~laney/ubuntu-system-settings/fix-translated-search
Merge into: lp:ubuntu-system-settings
Diff against target: 23 lines (+4/-3)
1 file modified
src/item-model.cpp (+4/-3)
To merge this branch: bzr merge lp:~laney/ubuntu-system-settings/fix-translated-search
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+195610@code.launchpad.net

Commit message

When generating the translated list of keywords, keep the byte array alive for as long as it's needed.

Description of the change

When generating the translated list of keywords, keep the byte array alive for as long as it's needed.

Otherwise it can be freed and then we get invalid reads which breaks the translations and means you can't search for the translated text.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

seems good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/item-model.cpp'
2--- src/item-model.cpp 2013-09-06 09:40:03 +0000
3+++ src/item-model.cpp 2013-11-18 14:00:00 +0000
4@@ -108,7 +108,9 @@
5 ret = QVariant::fromValue<QObject*>(const_cast<Plugin*>(item));
6 break;
7 case KeywordRole:
8- const char * domain = item->translations().toUtf8().constData();
9+ QByteArray translations = item->translations().toUtf8();
10+ QByteArray displayName = item->displayName().toUtf8();
11+ const char * domain = translations.constData();
12 QStringList temp(item->keywords());
13 QMutableListIterator<QString> it(temp);
14 while (it.hasNext()) {
15@@ -119,8 +121,7 @@
16 keyword.toUtf8().constData())));
17 }
18 temp << QString::fromUtf8(
19- dgettext(domain,
20- item->displayName().toUtf8().constData()));
21+ dgettext(domain,displayName.constData()));
22 ret = temp;
23 }
24

Subscribers

People subscribed via source and target branches