Commit bbe0acb2 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.Model: allowing some diagnostics for exceptions

Setting QTCREATOR_QTQUICKDESIGNER_WARN_EXCEPTION will give detailed
information about any exception thrown.

Change-Id: Ia11b98324e6f0c27e086778ddcb1afec67d92e6a
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent a66c122d
......@@ -84,6 +84,12 @@ bool Exception::shouldAssert()
return s_shouldAssert;
}
bool Exception::warnAboutException()
{
static bool warnException = !qgetenv("QTCREATOR_QTQUICKDESIGNER_WARN_EXCEPTION").isEmpty();
return warnException;
}
/*!
Constructs an exception. \a line uses the __LINE__ macro, \a function uses
the __FUNCTION__ or the Q_FUNC_INFO macro, and \a file uses
......@@ -125,6 +131,12 @@ QString Exception::backTrace() const
return m_backTrace;
}
void Exception::createWarning() const
{
if (warnAboutException())
qDebug() << *this;
}
/*!
Returns the optional description of this exception as a string.
*/
......
......@@ -50,7 +50,7 @@ InvalidArgumentException::InvalidArgumentException(int line,
const QString &argument)
: Exception(line, function, file), m_argument(argument)
{
createWarning();
}
QString InvalidArgumentException::description() const
......
......@@ -56,6 +56,7 @@ InvalidIdException::InvalidIdException(int line,
m_id(id),
m_description(description)
{
createWarning();
}
QString InvalidIdException::type() const
......
......@@ -48,6 +48,7 @@ InvalidMetaInfoException::InvalidMetaInfoException(int line,
const QString &file)
: Exception(line, function, file)
{
createWarning();
}
/*!
......
......@@ -48,6 +48,7 @@ InvalidModelNodeException::InvalidModelNodeException(int line,
const QString &file)
: Exception(line, function, file)
{
createWarning();
}
/*!
......
......@@ -49,6 +49,7 @@ InvalidModelStateException::InvalidModelStateException(int line,
const QString &file)
: Exception(line, function, file)
{
createWarning();
}
/*!
......
......@@ -48,6 +48,7 @@ InvalidPropertyException::InvalidPropertyException(int line,
const QString &argument)
: Exception(line, function, file), m_argument(argument)
{
createWarning();
}
/*!
......
......@@ -49,6 +49,7 @@ InvalidQmlSourceException::InvalidQmlSourceException(int line,
: Exception(line, function, file),
m_qmlSource(qmlSource)
{
createWarning();
}
/*!
......
......@@ -47,6 +47,7 @@ InvalidReparentingException::InvalidReparentingException(int line,
const QString &file)
: Exception(line, function, file)
{
createWarning();
}
/*!
......
......@@ -48,6 +48,7 @@ InvalidSlideIndexException::InvalidSlideIndexException(int line,
const QString &file)
: Exception(line, function, file)
{
createWarning();
}
/*!
......
......@@ -47,6 +47,7 @@ ModificationGroupException::ModificationGroupException(int line,
const QString &file)
: Exception(line, function, file)
{
createWarning();
}
/*!
......
......@@ -48,6 +48,7 @@ RemoveBaseStateException::RemoveBaseStateException(int line,
const QString &file)
: Exception(line, function, file)
{
createWarning();
}
/*!
......
......@@ -38,6 +38,7 @@ RewritingException::RewritingException(int line,
const QString &documentTextContent):
Exception(line, function, file), m_description(description), m_documentTextContent(documentTextContent)
{
createWarning();
}
QString RewritingException::type() const
......
......@@ -53,8 +53,11 @@ public:
QString file() const;
QString backTrace() const;
void createWarning() const;
static void setShouldAssert(bool assert);
static bool shouldAssert();
static bool warnAboutException();
private:
int m_line;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment