From a3b99232610211033acadb3aef59209d4c7b2a8e Mon Sep 17 00:00:00 2001 From: waxfrenzy Date: Tue, 12 Nov 2002 19:32:05 +0000 Subject: [PATCH] Fixed duplicate name drop-down bug. Duplicated names now numbered. --- SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.C | 19 +++++++++++++++++++ SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.h | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.C b/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.C index 1c0f45a..747b358 100644 --- a/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.C +++ b/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.C @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -102,6 +103,23 @@ LADSPAInfo::RescanPlugins(void) // Sort list by name sort(m_OrderedPluginList.begin(), m_OrderedPluginList.end(), PluginEntrySortAsc()); + +// Deal with duplicates by numbering them + for (vector::iterator i = m_OrderedPluginList.begin(); + i != m_OrderedPluginList.end(); ) { + string name = i->Name; + + i++; + unsigned long n = 2; + while ((i != m_OrderedPluginList.end()) && (i->Name == name)) { + stringstream s; + s << n; + i->Name = name + " (" + s.str() + ")"; + cerr << " " << n << endl; + n++; + i++; + } + } } void @@ -260,6 +278,7 @@ LADSPAInfo::ExaminePath(const char *path) bool path_added = false; bool library_added; string fullpath; + vector temp_names; dp = opendir(path); if (!dp) { diff --git a/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.h b/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.h index b7d62c6..b9edaaa 100644 --- a/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.h +++ b/SpiralSound/Plugins/LADSPAPlugin/LADSPAInfo.h @@ -62,7 +62,8 @@ public: std::string Name; }; - // Get a list of plugins ordered by name + // Get a list of plugins ordered by name (duplicate names are + // appended with a (number) const std::vector GetPluginList(void); // Get the index in the above list for given Unique ID