<table><tr><td style="">amhndu added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D15743">View Revision</a></tr></table><br /><div><div><p>Patch to move the key set as a member:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="diff" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);"><span style="color: #000080">diff --git a/plugins/externalscript/externalscriptplugin.cpp b/plugins/externalscript/externalscriptplugin.cpp</span>
<span style="color: #000080">index e1009457c8..3f2bddeeff 100644</span>
<span style="color: #a00000">--- a/plugins/externalscript/externalscriptplugin.cpp</span>
<span style="color: #00a000">+++ b/plugins/externalscript/externalscriptplugin.cpp</span>
<span style="color: #800080">@@ -120,6 +120,7 @@ ExternalScriptPlugin::ExternalScriptPlugin( QObject* parent, const QVariantList&</span>
       item->action()->setShortcut( QKeySequence( script.readEntry( "shortcuts" ) ) );
       item->setShowOutput( script.readEntry( "showOutput", true ) );
       m_model->appendRow( item );
<span style="color: #00a000">+      m_keySet.insert( script.name() );</span>
     }
   }
   //END load config
<span style="color: #800080">@@ -350,6 +351,7 @@ void ExternalScriptPlugin::rowsAboutToBeRemoved( const QModelIndex& /*parent*/,</span>
     const ExternalScriptItem* const item = static_cast<ExternalScriptItem*>( m_model->item( row ) );
     KConfigGroup child = config.group( item->key() );
     qCDebug(PLUGIN_EXTERNALSCRIPT) << "removing config group:" << child.name();
<span style="color: #00a000">+    m_keySet.remove( item->key() );</span>
     child.deleteGroup();
   }
   config.sync();
<span style="color: #800080">@@ -361,7 +363,10 @@ void ExternalScriptPlugin::updateItem( const ExternalScriptItem* item )</span>
   Q_ASSERT( index.isValid() );
 
   getConfig().group( item->key() ).deleteGroup(); // delete the previous group
<span style="color: #00a000">+  m_keySet.remove( item->key() );</span>
<span style="color: #00a000">+</span>
   setupKeys( index.row(), index.row() );
<span style="color: #00a000">+</span>
   saveItemForRow( index.row() ); // save the new group
 }
 
<span style="color: #800080">@@ -389,28 +394,18 @@ void ExternalScriptPlugin::saveItemForRow( int row )</span>
 
 void ExternalScriptPlugin::setupKeys(int start, int end)
 {
<span style="color: #a00000">-  QSet<QString> keySet;</span>
<span style="color: #a00000">-  for ( int row = 0; row < m_model->rowCount(); ++row ) {</span>
<span style="color: #a00000">-    if (row == start) {</span>
<span style="color: #a00000">-      row = end;</span>
<span style="color: #a00000">-    } else {</span>
<span style="color: #a00000">-      const ExternalScriptItem* const item = static_cast<ExternalScriptItem*>( m_model->item( row ) );</span>
<span style="color: #a00000">-      keySet.insert( item->key() );</span>
<span style="color: #a00000">-    }</span>
<span style="color: #a00000">-  }</span>
<span style="color: #a00000">-</span>
   for ( int row = start; row <= end; ++row ) {
     ExternalScriptItem* const item = static_cast<ExternalScriptItem*>( m_model->item( row ) );
 
<span style="color: #a00000">-    int maxSuffix = 0;</span>
<span style="color: #a00000">-    QString keyCandidate = item->text() + QString::number( maxSuffix );</span>
<span style="color: #a00000">-    for (; keySet.contains( keyCandidate ); ++maxSuffix) {</span>
<span style="color: #a00000">-      keyCandidate = item->text() + QString::number( maxSuffix);</span>
<span style="color: #00a000">+    int nextSuffix = 0;</span>
<span style="color: #00a000">+    QString keyCandidate = keyCandidate = item->text() + QString::number( nextSuffix );</span>
<span style="color: #00a000">+    for ( ++nextSuffix; m_keySet.contains( keyCandidate ); ++nextSuffix ) {</span>
<span style="color: #00a000">+      keyCandidate = item->text() + QString::number( nextSuffix );</span>
     }
 
     qCDebug(PLUGIN_EXTERNALSCRIPT) << "set key" << keyCandidate << "for" << item << item->command();
     item->setKey(keyCandidate);
<span style="color: #a00000">-    keySet.insert(keyCandidate);</span>
<span style="color: #00a000">+    m_keySet.insert(keyCandidate);</span>
   }
 }
 
<span style="color: #000080">diff --git a/plugins/externalscript/externalscriptplugin.h b/plugins/externalscript/externalscriptplugin.h</span>
<span style="color: #000080">index 068efc2de7..4c7ed73d12 100644</span>
<span style="color: #a00000">--- a/plugins/externalscript/externalscriptplugin.h</span>
<span style="color: #00a000">+++ b/plugins/externalscript/externalscriptplugin.h</span>
<span style="color: #800080">@@ -26,6 +26,7 @@</span>
 #include <QVariantList>
 #include <KConfigGroup>
 #include <QUrl>
<span style="color: #00a000">+#include <QSet></span>
 
 class ExternalScriptItem;
 
<span style="color: #800080">@@ -101,6 +102,7 @@ private:</span>
 
   QStandardItemModel* m_model;
   QList<QUrl> m_urls;
<span style="color: #00a000">+  QSet<QString> m_keySet;</span>
   static ExternalScriptPlugin* m_self;
 
   class ExternalScriptViewFactory *m_factory;</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D15743">https://phabricator.kde.org/D15743</a></div></div><br /><div><strong>To: </strong>amhndu, KDevelop<br /><strong>Cc: </strong>flherne, kdevelop-devel, glebaccon, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>