diff main/MainWindow.h @ 2093:6e3ef3aa341e spectrogramparam

Ensure that operations that need to iterate through action maps in order (most pointedly MainWindow::updateLayerShortcutsFor) get to do it in order of construction and not arbitrary pointer order. Fixes incorrect shortcut associations for add-layer/pane shortcuts in some cases
author Chris Cannam
date Tue, 13 Nov 2018 14:09:30 +0000
parents 2b83ca602ece
children 124de219669f c476db6cf3eb
line wrap: on
line diff
--- a/main/MainWindow.h	Tue Nov 13 14:09:25 2018 +0000
+++ b/main/MainWindow.h	Tue Nov 13 14:09:30 2018 +0000
@@ -249,29 +249,39 @@
 
     QString shortcutFor(LayerFactory::LayerType, bool isPaneMenu);
     void updateLayerShortcutsFor(Model *);
+
+    // Map from menu action to the resulting layer configurations
+    // etc. These all used to be std::maps, but we sometimes want to
+    // iterate through actions in order of creation, not in order of
+    // arbitrary QAction pointer. And speed of random lookup is not
+    // important.
+    //
+    // Some of these would still be fine as maps, but we might as well
+    // consistently use the same arrangement throughout.
     
-    typedef std::map<QAction *, LayerConfiguration> PaneActionMap;
-    PaneActionMap m_paneActions;
+    typedef std::vector<std::pair<QAction *, LayerConfiguration>> PaneActions;
+    PaneActions m_paneActions;
 
-    typedef std::map<QAction *, LayerConfiguration> LayerActionMap;
-    LayerActionMap m_layerActions;
+    typedef std::vector<std::pair<QAction *, LayerConfiguration>> LayerActions;
+    LayerActions m_layerActions;
 
-    typedef std::map<QAction *, TransformId> TransformActionMap;
-    TransformActionMap m_transformActions;
+    typedef std::vector<std::pair<QAction *, Layer *>> ExistingLayerActions;
+    ExistingLayerActions m_existingLayerActions;
+    ExistingLayerActions m_sliceActions;
 
+    typedef std::vector<std::pair<ViewManager::ToolMode, QAction *>> ToolActions;
+    ToolActions m_toolActions;
+
+    typedef std::vector<std::pair<QAction *, int>> NumberingActions;
+    NumberingActions m_numberingActions;
+
+    typedef std::vector<std::pair<QAction *, TransformId>> TransformActions;
+    TransformActions m_transformActions;
+
+    // This one only makes sense as a map though
     typedef std::map<TransformId, QAction *> TransformActionReverseMap;
     TransformActionReverseMap m_transformActionsReverse;
 
-    typedef std::map<QAction *, Layer *> ExistingLayerActionMap;
-    ExistingLayerActionMap m_existingLayerActions;
-    ExistingLayerActionMap m_sliceActions;
-
-    typedef std::map<ViewManager::ToolMode, QAction *> ToolActionMap;
-    ToolActionMap m_toolActions;
-
-    typedef std::map<QAction *, int> NumberingActionMap;
-    NumberingActionMap m_numberingActions;
-
     QString getReleaseText() const;
     
     virtual void setupMenus();