diff --git a/src/help/tipsandtricks.cpp b/src/help/tipsandtricks.cpp
index 6af0b971d..a38bbec13 100644
--- a/src/help/tipsandtricks.cpp
+++ b/src/help/tipsandtricks.cpp
@@ -200,6 +200,8 @@ void TipsAndTricks::cleanup() {
delete Singleton;
Singleton = NULL;
}
+ while (!TipSets.isEmpty())
+ delete TipSets.takeFirst();
}
const QString & TipsAndTricks::randomTip() {
diff --git a/src/program/highlighter.cpp b/src/program/highlighter.cpp
index b8ba324a9..c48b1ba57 100644
--- a/src/program/highlighter.cpp
+++ b/src/program/highlighter.cpp
@@ -30,7 +30,7 @@ along with Fritzing. If not, see .
#define COMMENTOFFSET 100
static const QChar CEscapeChar('\\');
-QHash Highlighter::m_styleFormats;
+QHash Highlighter::m_styleFormats;
Highlighter::Highlighter(QTextEdit * textEdit) : QSyntaxHighlighter(textEdit)
{
@@ -59,24 +59,24 @@ void Highlighter::loadStyles(const QString & filename) {
QDomElement style = root.firstChildElement("style");
while (!style.isNull()) {
- QTextCharFormat * tcf = new QTextCharFormat();
+ QTextCharFormat tcf;
QColor color(Qt::black);
QString colorString = style.attribute("color");
if (!colorString.isEmpty()) {
color.setNamedColor(colorString);
- tcf->setForeground(QBrush(color));
+ tcf.setForeground(QBrush(color));
}
QString italicString = style.attribute("italic");
if (italicString.compare("1") == 0) {
- tcf->setFontItalic(true);
+ tcf.setFontItalic(true);
}
QString boldString = style.attribute("bold");
if (boldString.compare("1") == 0) {
- tcf->setFontWeight(QFont::Bold);
+ tcf.setFontWeight(QFont::Bold);
}
QString underlineString = style.attribute("underline");
if (underlineString.compare("1") == 0) {
- tcf->setFontUnderline(true);
+ tcf.setFontUnderline(true);
}
m_styleFormats.insert(style.attribute("name"), tcf);
@@ -131,9 +131,8 @@ void Highlighter::highlightBlock(const QString &text)
commentLength = endIndex - startCommentIndex + currentCommentInfo->m_end.length();
}
noComment.replace(startCommentIndex, commentLength, QString(commentLength, ' '));
- QTextCharFormat * cf = m_styleFormats.value("Comment", NULL);
- if (cf) {
- setFormat(startCommentIndex, commentLength, *cf);
+ if (m_styleFormats.contains("Comment")) {
+ setFormat(startCommentIndex, commentLength, m_styleFormats.value("Comment"));
}
m_syntaxer->matchCommentStart(text, startCommentIndex + commentLength, startCommentIndex, currentCommentInfo);
}
@@ -177,9 +176,8 @@ void Highlighter::highlightStrings(int startStringIndex, QString & text) {
stringLength = endIndex - startStringIndex + 1;
}
text.replace(startStringIndex, stringLength, QString(stringLength, ' '));
- QTextCharFormat * sf = m_styleFormats.value("String", NULL);
- if (sf) {
- setFormat(startStringIndex, stringLength, *sf);
+ if (m_styleFormats.contains("String")) {
+ setFormat(startStringIndex, stringLength, m_styleFormats.value("String"));
}
startStringIndex = m_syntaxer->matchStringStart(text, startStringIndex + stringLength);
}
@@ -200,9 +198,8 @@ void Highlighter::highlightTerms(const QString & text) {
SyntaxerTrieLeaf * stl = dynamic_cast(leaf);
if (stl) {
QString format = Syntaxer::formatFromList(stl->name());
- QTextCharFormat * tcf = m_styleFormats.value(format, NULL);
- if (tcf) {
- setFormat(lastWordBreak, b - lastWordBreak, *tcf);
+ if (m_styleFormats.contains(format)) {
+ setFormat(lastWordBreak, b - lastWordBreak, m_styleFormats.value(format));
}
}
}
diff --git a/src/program/highlighter.h b/src/program/highlighter.h
index 262bd8b83..c9dd27627 100644
--- a/src/program/highlighter.h
+++ b/src/program/highlighter.h
@@ -51,7 +51,7 @@ class Highlighter : public QSyntaxHighlighter
protected:
QPointer m_syntaxer;
- static QHash m_styleFormats;
+ static QHash m_styleFormats;
};
#endif /* HIGHLIGHTER_H_ */