Skip to content

Commit a6770e7

Browse files
committed
fix: app crashed when parsing Actions for notification
as title. Log: as title. pms: TASK-366403
1 parent 69f2200 commit a6770e7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

panels/notification/center/notifyitem.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,18 @@ QVariantList AppNotifyItem::actions() const
117117
void AppNotifyItem::updateActions()
118118
{
119119
QStringList actions = m_entity.actions();
120-
const auto defaultIndex = actions.indexOf(QLatin1String("default"));
121-
if (defaultIndex >= 0) {
122-
actions.remove(defaultIndex, 2);
120+
if (actions.contains(QLatin1String("default"))) {
121+
actions.removeAll(QLatin1String("default"));
123122
m_defaultAction = QLatin1String("default");
124123
}
125124

125+
Q_ASSERT(actions.size() % 2 != 1);
126+
if (actions.size() % 2 == 1) {
127+
qWarning(notifyLog) << "Actions must be an even number except for default, The notify appName:" << m_entity.appName()
128+
<< ", actions:" << m_entity.actions();
129+
return;
130+
}
131+
126132
QVariantList array;
127133
for (int i = 0; i < actions.size(); i += 2) {
128134
const auto id = actions[i];

0 commit comments

Comments
 (0)