Skip to content

Commit

Permalink
[Devices] Fix showing all included plugins in devices pull-down list
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-er committed Jun 22, 2023
1 parent 9347ad1 commit 3046d14
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/src/Globals/Plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

int deviceCount = -1;

deviceIndex_t* DeviceIndex_sorted = nullptr;
std::vector<deviceIndex_t> DeviceIndex_sorted;


bool validDeviceIndex(deviceIndex_t index) {
Expand Down
3 changes: 2 additions & 1 deletion src/src/Globals/Plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../DataTypes/DeviceIndex.h"
#include "../DataTypes/TaskIndex.h"

#include <vector>

/********************************************************************************************\
Structures to address the plugins and device configurations.
Expand Down Expand Up @@ -44,7 +45,7 @@ extern int deviceCount;


// Array containing "DeviceIndex" alfabetically sorted.
extern deviceIndex_t* DeviceIndex_sorted;
extern std::vector<deviceIndex_t> DeviceIndex_sorted;


bool validDeviceIndex(deviceIndex_t index);
Expand Down
34 changes: 9 additions & 25 deletions src/src/Helpers/_Plugin_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2159,36 +2159,20 @@ void PluginSetup()
// ********************************************************************************

// First fill the existing number of the DeviceIndex.
if (DeviceIndex_sorted) {
delete[] DeviceIndex_sorted;
DeviceIndex_sorted = nullptr;
}
DeviceIndex_sorted = new deviceIndex_t[deviceCount + 1];

DeviceIndex_sorted.resize(deviceCount + 1);
for (deviceIndex_t x = 0; x <= deviceCount; x++) {
DeviceIndex_sorted[x] = getPluginID_from_DeviceIndex(x);
DeviceIndex_sorted[x] = x;
}

// Do the sorting.
int innerLoop;
int mainLoop;

for (mainLoop = 1; mainLoop <= deviceCount; mainLoop++)
struct
{
innerLoop = mainLoop;

while (innerLoop >= 1)
{
const String cur(getPluginNameFromDeviceIndex(DeviceIndex_sorted[innerLoop]));
const String prev(getPluginNameFromDeviceIndex(DeviceIndex_sorted[innerLoop - 1]));
if (cur < prev) {
deviceIndex_t temp = DeviceIndex_sorted[innerLoop - 1];
DeviceIndex_sorted[innerLoop - 1] = DeviceIndex_sorted[innerLoop];
DeviceIndex_sorted[innerLoop] = temp;
}
innerLoop--;
bool operator()(deviceIndex_t a, deviceIndex_t b) const {
return getPluginNameFromDeviceIndex(a) <
getPluginNameFromDeviceIndex(b);
}
}
}
customLess;
std::sort(DeviceIndex_sorted.begin(), DeviceIndex_sorted.end(), customLess);
}

void PluginInit(bool priorityOnly)
Expand Down

0 comments on commit 3046d14

Please sign in to comment.