GLSL: Fix crash when built with Qt 6

In Qt 6 references (and pointers) to elements in a container are
invalidated when the container size changes. Simply move to
std::unordered_set which guarantees references to stay valid.

Fixes: QTCREATORBUG-25641
Task-number: QTCREATORBUG-24098
Change-Id: I9f1110419bd2940c182b4a24629d9ab718ca2af6
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2021-05-20 09:37:15 +02:00
parent 76d8483d16
commit e4db67b523
2 changed files with 12 additions and 11 deletions

View File

@@ -29,9 +29,10 @@
#include "glslmemorypool.h"
#include "glsltypes.h"
#include <qstring.h>
#include <qset.h>
#include <functional>
#include <set>
#include <unordered_set>
namespace GLSL {
@@ -91,11 +92,11 @@ public:
const QString *identifier(const QString &s);
const QString *identifier(const char *s, int n);
QSet<QString> identifiers() const;
std::unordered_set<QString> identifiers() const;
const QString *number(const QString &s);
const QString *number(const char *s, int n);
QSet<QString> numbers() const;
std::unordered_set<QString> numbers() const;
// types
const UndefinedType *undefinedType();
@@ -128,8 +129,8 @@ public:
void error(int line, const QString &message);
private:
QSet<QString> _identifiers;
QSet<QString> _numbers;
std::unordered_set<QString> _identifiers;
std::unordered_set<QString> _numbers;
TypeTable<VectorType> _vectorTypes;
TypeTable<MatrixType> _matrixTypes;
TypeTable<ArrayType> _arrayTypes;