summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-04-23 17:46:55 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-24 09:35:22 +0200
commitc9542b0538e0ceadba244b6208099b5513951976 (patch)
treef3517ca54de9df3d1d27cac7ab1d9d3314dc1b57
parent52de1b9b3ff7508ca7db70d677e4afe8835c5577 (diff)
downloadqttools-c9542b0538e0ceadba244b6208099b5513951976.tar.gz
Don't use the QRegExp methods that modify the object [Designer]
QRegExp matching methods modify the object, which we don't want to. In particular, when we receive a QRegExp from the user or we store in a context that might require thread-safety, make sure we make a copy before using it. QRegularExpression has no such shortcoming. Task-number: QTBUG-25064 Change-Id: I58984ddce6a44cca7fe5a7b36e4595bad791d976 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
-rw-r--r--src/designer/src/components/formeditor/formwindowsettings.cpp2
-rw-r--r--src/designer/src/components/formeditor/layout_propertysheet.cpp2
-rw-r--r--src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp2
-rw-r--r--src/designer/src/components/widgetbox/widgetboxtreewidget.cpp2
-rw-r--r--src/designer/src/lib/shared/formlayoutmenu.cpp2
-rw-r--r--src/designer/src/lib/shared/qdesigner_widgetbox.cpp2
-rw-r--r--src/designer/src/lib/shared/signalslotdialog.cpp10
-rw-r--r--src/designer/src/lib/shared/textpropertyeditor.cpp4
8 files changed, 14 insertions, 12 deletions
diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp
index 2b546bebc..371315e0d 100644
--- a/src/designer/src/components/formeditor/formwindowsettings.cpp
+++ b/src/designer/src/components/formeditor/formwindowsettings.cpp
@@ -226,7 +226,7 @@ FormWindowData FormWindowSettings::data() const
if (!hints.isEmpty()) {
rc.includeHints = hints.split(QString(QLatin1Char('\n')));
// Purge out any lines consisting of blanks only
- const QRegExp blankLine = QRegExp(QStringLiteral("^\\s*$"));
+ QRegExp blankLine = QRegExp(QStringLiteral("^\\s*$"));
Q_ASSERT(blankLine.isValid());
for (QStringList::iterator it = rc.includeHints.begin(); it != rc.includeHints.end(); )
if (blankLine.exactMatch(*it)) {
diff --git a/src/designer/src/components/formeditor/layout_propertysheet.cpp b/src/designer/src/components/formeditor/layout_propertysheet.cpp
index 08048d1e9..2b79043c1 100644
--- a/src/designer/src/components/formeditor/layout_propertysheet.cpp
+++ b/src/designer/src/components/formeditor/layout_propertysheet.cpp
@@ -107,7 +107,7 @@ namespace {
static bool isIntegerList(const QString &s)
{
// Check for empty string or comma-separated list of integers
- static const QRegExp re(QStringLiteral("[0-9]+(,[0-9]+)+"));
+ static QRegExp re(QStringLiteral("[0-9]+(,[0-9]+)+"));
Q_ASSERT(re.isValid());
return s.isEmpty() || re.exactMatch(s);
}
diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
index f32e797c5..14eb1672b 100644
--- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
+++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
@@ -364,7 +364,7 @@ QWidget *WidgetBoxCategoryEntryDelegate::createEditor(QWidget *parent,
{
QWidget *result = QItemDelegate::createEditor(parent, option, index);
if (QLineEdit *line_edit = qobject_cast<QLineEdit*>(result)) {
- const QRegExp re = QRegExp(QStringLiteral("[_a-zA-Z][_a-zA-Z0-9]*"));
+ QRegExp re = QRegExp(QStringLiteral("[_a-zA-Z][_a-zA-Z0-9]*"));
Q_ASSERT(re.isValid());
line_edit->setValidator(new QRegExpValidator(re, line_edit));
}
diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp
index d302a39a2..a489d3a2f 100644
--- a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp
+++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp
@@ -971,7 +971,7 @@ void WidgetBoxTreeWidget::dropWidgets(const QList<QDesignerDnDItemInterface*> &i
void WidgetBoxTreeWidget::filter(const QString &f)
{
const bool empty = f.isEmpty();
- const QRegExp re = empty ? QRegExp() : QRegExp(f, Qt::CaseInsensitive, QRegExp::FixedString);
+ QRegExp re = empty ? QRegExp() : QRegExp(f, Qt::CaseInsensitive, QRegExp::FixedString);
const int numTopLevels = topLevelItemCount();
bool changed = false;
for (int i = 0; i < numTopLevels; i++) {
diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp
index 713e930ba..fd7aa27f4 100644
--- a/src/designer/src/lib/shared/formlayoutmenu.cpp
+++ b/src/designer/src/lib/shared/formlayoutmenu.cpp
@@ -130,7 +130,7 @@ private:
void updateOkButton();
// Check for buddy marker in string
- const QRegExp m_buddyMarkerRegexp;
+ QRegExp m_buddyMarkerRegexp;
Ui::FormLayoutRowDialog m_ui;
bool m_labelNameEdited;
diff --git a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp
index 0b868f407..31a49f5fb 100644
--- a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp
+++ b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp
@@ -170,7 +170,7 @@ bool QDesignerWidgetBox::findWidget(const QDesignerWidgetBoxInterface *wbox,
QString pattern = QStringLiteral("^<widget\\s+class\\s*=\\s*\"");
pattern += className;
pattern += QStringLiteral("\".*$");
- const QRegExp regexp(pattern);
+ QRegExp regexp(pattern);
Q_ASSERT(regexp.isValid());
const int catCount = wbox->categoryCount();
for (int c = 0; c < catCount; c++) {
diff --git a/src/designer/src/lib/shared/signalslotdialog.cpp b/src/designer/src/lib/shared/signalslotdialog.cpp
index d261a2411..73c409f18 100644
--- a/src/designer/src/lib/shared/signalslotdialog.cpp
+++ b/src/designer/src/lib/shared/signalslotdialog.cpp
@@ -138,8 +138,8 @@ namespace {
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
private:
- const QRegExp m_signatureRegexp;
- const QRegExp m_methodNameRegexp;
+ QRegExp m_signatureRegexp;
+ QRegExp m_methodNameRegexp;
};
SignatureDelegate::SignatureDelegate(QObject * parent) :
@@ -166,8 +166,10 @@ namespace {
Q_ASSERT(le);
// Did the user just type a name? .. Add parentheses
QString signature = le->text();
- if (!m_signatureRegexp.exactMatch(signature )) {
- if (m_methodNameRegexp.exactMatch(signature )) {
+ QRegExp signatureRegexp = m_signatureRegexp;
+ QRegExp methodNameRegexp = m_methodNameRegexp;
+ if (!signatureRegexp.exactMatch(signature )) {
+ if (methodNameRegexp.exactMatch(signature )) {
signature += QStringLiteral("()");
le->setText(signature);
} else {
diff --git a/src/designer/src/lib/shared/textpropertyeditor.cpp b/src/designer/src/lib/shared/textpropertyeditor.cpp
index 3471abc9a..da97a8af6 100644
--- a/src/designer/src/lib/shared/textpropertyeditor.cpp
+++ b/src/designer/src/lib/shared/textpropertyeditor.cpp
@@ -168,7 +168,7 @@ namespace {
QUrl UrlValidator::guessUrlFromString(const QString &string) const
{
const QString urlStr = string.trimmed();
- const QRegExp qualifiedUrl(QStringLiteral("^[a-zA-Z]+\\:.*"));
+ QRegExp qualifiedUrl(QStringLiteral("^[a-zA-Z]+\\:.*"));
// Check if it looks like a qualified URL. Try parsing it and see.
const bool hasSchema = qualifiedUrl.exactMatch(urlStr);
@@ -299,7 +299,7 @@ namespace qdesigner_internal {
void TextPropertyEditor::setRegExpValidator(const QString &pattern)
{
- const QRegExp regExp(pattern);
+ QRegExp regExp(pattern);
Q_ASSERT(regExp.isValid());
m_lineEdit->setValidator(new QRegExpValidator(regExp,m_lineEdit));
}