Index: modules/shortcut/shortcut.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/shortcut/shortcut.module,v
retrieving revision 1.17
diff -u -r1.17 shortcut.module
--- modules/shortcut/shortcut.module	11 Jan 2010 00:06:58 -0000	1.17
+++ modules/shortcut/shortcut.module	13 Jan 2010 17:24:23 -0000
@@ -265,13 +265,23 @@
   }
   // If links were provided for the set, save them.
   if (isset($shortcut_set->links)) {
-    foreach ($shortcut_set->links as &$link) {
+    //We will store all mlids in order to be able to remove any other links that should not be in the set.
+    $mlids = array();
+  	foreach ($shortcut_set->links as &$link) {
       // Do not specifically associate these links with the shortcut module,
       // since other modules may make them editable via the menu system.
       // However, we do need to specify the correct menu name.
       $link['menu_name'] = $shortcut_set->set_name;
       $link['plid'] = 0;
-      menu_link_save($link);
+      $mlids[] = menu_link_save($link);
+    }
+    //Make sure that the links provided in the set are the only ones actually in the set.
+    $links = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC))
+    ->fields('ml',array('mlid'))
+    ->condition('menu_name',$shortcut_set->set_name,'=')
+    ->condition('mlid',$mlids,'NOT IN');
+    foreach($links as &$link){
+      menu_link_delete($link['mlid']);
     }
     // Make sure that we have a return value, since if the links were updated
     // but the shortcut set was not, the call to drupal_write_record() above
