commit 5ded0d002d216f630b7e95f07e551c795c96828b
Author: Guillaume Munch <[email protected]>
Date: Thu Aug 4 17:00:21 2016 +0100
Assertions when doing Export As... (#10321)
Fix assertion with gcc 6: The comparison function must be a strict weak
orderings and not give x < x.
Fix assertion when a custom exportable document format is given a non-ASCII
name. Use qt_ to be consistent with the rest of the code.
Use Qt's locale-aware comparison for appropriate sorting.
---
src/frontends/qt4/GuiView.cpp | 17 ++++++-----------
1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index d2c835c..b6d4522 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -2569,15 +2569,6 @@ bool GuiView::renameBuffer(Buffer & b, docstring const &
newname, RenameKind kin
}
-struct PrettyNameComparator
-{
- bool operator()(Format const *first, Format const *second) const {
- return
compare_no_case(translateIfPossible(from_ascii(first->prettyname())),
-
translateIfPossible(from_ascii(second->prettyname()))) <= 0;
- }
-};
-
-
bool GuiView::exportBufferAs(Buffer & b, docstring const & iformat)
{
FileName fname = b.fileName();
@@ -2593,8 +2584,12 @@ bool GuiView::exportBufferAs(Buffer & b, docstring const
& iformat)
for (; it != formats.end(); ++it)
if (it->documentFormat())
export_formats.push_back(&(*it));
- PrettyNameComparator cmp;
- sort(export_formats.begin(), export_formats.end(), cmp);
+ sort(export_formats.begin(), export_formats.end(),
+ [](Format const *first, Format const *second) {
+ QString name1 = qt_(first->prettyname());
+ QString name2 = qt_(second->prettyname());
+ return 0 < name2.localeAwareCompare(name1);
+ });
vector<Format const *>::const_iterator fit = export_formats.begin();
map<QString, string> fmap;
QString filter;