File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -243,12 +243,18 @@ QVariantList BubbleItem::actions() const
243243void BubbleItem::updateActions ()
244244{
245245 QStringList actions = m_entity.actions ();
246- const auto defaultIndex = actions.indexOf (QLatin1String (" default" ));
247- if (defaultIndex >= 0 ) {
248- actions.remove (defaultIndex, 2 );
246+ if (actions.contains (QLatin1String (" default" ))) {
247+ actions.removeAll (QLatin1String (" default" ));
249248 m_defaultAction = QLatin1String (" default" );
250249 }
251250
251+ Q_ASSERT (actions.size () % 2 != 1 );
252+ if (actions.size () % 2 == 1 ) {
253+ qWarning (notifyLog) << " Actions must be an even number except for default, The notify appName:" << m_entity.appName ()
254+ << " , actions:" << m_entity.actions ();
255+ return ;
256+ }
257+
252258 QVariantList array;
253259 for (int i = 0 ; i < actions.size (); i += 2 ) {
254260 const auto id = actions[i];
Original file line number Diff line number Diff line change @@ -117,12 +117,18 @@ QVariantList AppNotifyItem::actions() const
117117void 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];
You can’t perform that action at this time.
0 commit comments