From 60c54ea83ac36628c5ca040943731bf73fdc6fa6 Mon Sep 17 00:00:00 2001 From: Alexander Miloslavskiy Date: Thu, 1 Nov 2018 21:15:26 +0100 Subject: [PATCH] Fixed incorrect comparator used in sorting xrefs * With old comparator, items {1, 2} and {2, 1} were "less" then each other. This will cause them to sort randomly. --- src/gui/Src/Gui/CPUInfoBox.cpp | 5 ++++- src/gui/Src/Gui/XrefBrowseDialog.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/Src/Gui/CPUInfoBox.cpp b/src/gui/Src/Gui/CPUInfoBox.cpp index 93ff2f30..b09789a8 100644 --- a/src/gui/Src/Gui/CPUInfoBox.cpp +++ b/src/gui/Src/Gui/CPUInfoBox.cpp @@ -257,7 +257,10 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA) std::sort(data.begin(), data.end(), [](const XREF_RECORD * A, const XREF_RECORD * B) { - return ((A->type < B->type) || (A->addr < B->addr)); + if (A->type != B->type) + return (A->type < B->type); + + return (A->addr < B->addr); }); int t = XREF_NONE; diff --git a/src/gui/Src/Gui/XrefBrowseDialog.cpp b/src/gui/Src/Gui/XrefBrowseDialog.cpp index 9ec42acf..23a5db84 100644 --- a/src/gui/Src/Gui/XrefBrowseDialog.cpp +++ b/src/gui/Src/Gui/XrefBrowseDialog.cpp @@ -58,7 +58,10 @@ void XrefBrowseDialog::setup(duint address, QString command) std::sort(data.begin(), data.end(), [](const XREF_RECORD A, const XREF_RECORD B) { - return ((A.type < B.type) || (A.addr < B.addr)); + if (A.type != B.type) + return (A.type < B.type); + + return (A.addr < B.addr); }); for(duint i = 0; i < mXrefInfo.refcount; i++)