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
=== modified file 'src/item-model.cpp'
--- src/item-model.cpp 2013-09-06 09:40:03 +0000
+++ src/item-model.cpp 2013-11-18 14:00:00 +0000
@@ -108,7 +108,9 @@
108 ret = QVariant::fromValue<QObject*>(const_cast<Plugin*>(item));108 ret = QVariant::fromValue<QObject*>(const_cast<Plugin*>(item));
109 break;109 break;
110 case KeywordRole:110 case KeywordRole:
111 const char * domain = item->translations().toUtf8().constData();111 QByteArray translations = item->translations().toUtf8();
112 QByteArray displayName = item->displayName().toUtf8();
113 const char * domain = translations.constData();
112 QStringList temp(item->keywords());114 QStringList temp(item->keywords());
113 QMutableListIterator<QString> it(temp);115 QMutableListIterator<QString> it(temp);
114 while (it.hasNext()) {116 while (it.hasNext()) {
@@ -119,8 +121,7 @@
119 keyword.toUtf8().constData())));121 keyword.toUtf8().constData())));
120 }122 }
121 temp << QString::fromUtf8(123 temp << QString::fromUtf8(
122 dgettext(domain,124 dgettext(domain,displayName.constData()));
123 item->displayName().toUtf8().constData()));
124 ret = temp;125 ret = temp;
125 }126 }
126127

Subscribers

People subscribed via source and target branches