forked from qt-creator/qt-creator
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: Marco Bubke <marco.bubke@digia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -84,6 +84,12 @@ bool Exception::shouldAssert()
|
|||||||
return s_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
|
Constructs an exception. \a line uses the __LINE__ macro, \a function uses
|
||||||
the __FUNCTION__ or the Q_FUNC_INFO macro, and \a file uses
|
the __FUNCTION__ or the Q_FUNC_INFO macro, and \a file uses
|
||||||
@@ -125,6 +131,12 @@ QString Exception::backTrace() const
|
|||||||
return m_backTrace;
|
return m_backTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Exception::createWarning() const
|
||||||
|
{
|
||||||
|
if (warnAboutException())
|
||||||
|
qDebug() << *this;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the optional description of this exception as a string.
|
Returns the optional description of this exception as a string.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ InvalidArgumentException::InvalidArgumentException(int line,
|
|||||||
const QString &argument)
|
const QString &argument)
|
||||||
: Exception(line, function, file), m_argument(argument)
|
: Exception(line, function, file), m_argument(argument)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString InvalidArgumentException::description() const
|
QString InvalidArgumentException::description() const
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ InvalidIdException::InvalidIdException(int line,
|
|||||||
m_id(id),
|
m_id(id),
|
||||||
m_description(description)
|
m_description(description)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString InvalidIdException::type() const
|
QString InvalidIdException::type() const
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ InvalidMetaInfoException::InvalidMetaInfoException(int line,
|
|||||||
const QString &file)
|
const QString &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ InvalidModelNodeException::InvalidModelNodeException(int line,
|
|||||||
const QString &file)
|
const QString &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ InvalidModelStateException::InvalidModelStateException(int line,
|
|||||||
const QString &file)
|
const QString &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ InvalidPropertyException::InvalidPropertyException(int line,
|
|||||||
const QString &argument)
|
const QString &argument)
|
||||||
: Exception(line, function, file), m_argument(argument)
|
: Exception(line, function, file), m_argument(argument)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ InvalidQmlSourceException::InvalidQmlSourceException(int line,
|
|||||||
: Exception(line, function, file),
|
: Exception(line, function, file),
|
||||||
m_qmlSource(qmlSource)
|
m_qmlSource(qmlSource)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ InvalidReparentingException::InvalidReparentingException(int line,
|
|||||||
const QString &file)
|
const QString &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ InvalidSlideIndexException::InvalidSlideIndexException(int line,
|
|||||||
const QString &file)
|
const QString &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ ModificationGroupException::ModificationGroupException(int line,
|
|||||||
const QString &file)
|
const QString &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ RemoveBaseStateException::RemoveBaseStateException(int line,
|
|||||||
const QString &file)
|
const QString &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ RewritingException::RewritingException(int line,
|
|||||||
const QString &documentTextContent):
|
const QString &documentTextContent):
|
||||||
Exception(line, function, file), m_description(description), m_documentTextContent(documentTextContent)
|
Exception(line, function, file), m_description(description), m_documentTextContent(documentTextContent)
|
||||||
{
|
{
|
||||||
|
createWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RewritingException::type() const
|
QString RewritingException::type() const
|
||||||
|
|||||||
@@ -53,8 +53,11 @@ public:
|
|||||||
QString file() const;
|
QString file() const;
|
||||||
QString backTrace() const;
|
QString backTrace() const;
|
||||||
|
|
||||||
|
void createWarning() const;
|
||||||
|
|
||||||
static void setShouldAssert(bool assert);
|
static void setShouldAssert(bool assert);
|
||||||
static bool shouldAssert();
|
static bool shouldAssert();
|
||||||
|
static bool warnAboutException();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_line;
|
int m_line;
|
||||||
|
|||||||
Reference in New Issue
Block a user