forked from qt-creator/qt-creator
QmlDesigner: Change signature of our exceptions to use QByteArray instead of QString
This allows to use macros like __FUNCTION__ for the exceptions if QT_NO_CAST_FROM_ASCII is defined. Change-Id: Ib629482bb60502cb311cb2657f1a73c730daf6aa Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
2dc48cb4ae
commit
b3b6d3fc71
@@ -100,11 +100,11 @@ bool Exception::warnAboutException()
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
Exception::Exception(int line,
|
Exception::Exception(int line,
|
||||||
const QString &function,
|
const QByteArray &_function,
|
||||||
const QString &file)
|
const QByteArray &_file)
|
||||||
: m_line(line),
|
: m_line(line),
|
||||||
m_function(function),
|
m_function(QString::fromLatin1(_function)),
|
||||||
m_file(file)
|
m_file(QString::fromLatin1(_file))
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
void * array[50];
|
void * array[50];
|
||||||
@@ -120,7 +120,7 @@ Exception::Exception(int line,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s_shouldAssert)
|
if (s_shouldAssert)
|
||||||
Q_ASSERT_X(false, function.toUtf8(), QString("%1:%2 - %3").arg(file).arg(line).arg(function).toUtf8());
|
Q_ASSERT_X(false, _function, QString(QStringLiteral("%1:%2 - %3")).arg(m_file).arg(m_line).arg(m_function).toLatin1());
|
||||||
}
|
}
|
||||||
|
|
||||||
Exception::~Exception()
|
Exception::~Exception()
|
||||||
|
@@ -46,10 +46,10 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidArgumentException::InvalidArgumentException(int line,
|
InvalidArgumentException::InvalidArgumentException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &argument)
|
const QByteArray &argument)
|
||||||
: Exception(line, function, file), m_argument(argument)
|
: Exception(line, function, file), m_argument(QString::fromLatin1(argument))
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
}
|
}
|
||||||
|
@@ -35,12 +35,12 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
InvalidIdException::InvalidIdException(int line,
|
InvalidIdException::InvalidIdException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &id,
|
const QByteArray &id,
|
||||||
Reason reason) :
|
Reason reason) :
|
||||||
InvalidArgumentException(line, function, file, "id"),
|
InvalidArgumentException(line, function, file, "id"),
|
||||||
m_id(id)
|
m_id(QString::fromLatin1(id))
|
||||||
{
|
{
|
||||||
if (reason == InvalidCharacters)
|
if (reason == InvalidCharacters)
|
||||||
m_description = QCoreApplication::translate("InvalidIdException", "Only alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter.");
|
m_description = QCoreApplication::translate("InvalidIdException", "Only alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter.");
|
||||||
@@ -49,13 +49,13 @@ InvalidIdException::InvalidIdException(int line,
|
|||||||
}
|
}
|
||||||
|
|
||||||
InvalidIdException::InvalidIdException(int line,
|
InvalidIdException::InvalidIdException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &id,
|
const QByteArray &id,
|
||||||
const QString &description) :
|
const QByteArray &description) :
|
||||||
InvalidArgumentException(line, function, file, "id"),
|
InvalidArgumentException(line, function, file, "id"),
|
||||||
m_id(id),
|
m_id(QString::fromLatin1(id)),
|
||||||
m_description(description)
|
m_description(QString::fromLatin1(description))
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,8 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidMetaInfoException::InvalidMetaInfoException(int line,
|
InvalidMetaInfoException::InvalidMetaInfoException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file)
|
const QByteArray &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
|
@@ -45,8 +45,8 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidModelNodeException::InvalidModelNodeException(int line,
|
InvalidModelNodeException::InvalidModelNodeException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file)
|
const QByteArray &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
|
@@ -46,8 +46,8 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidModelStateException::InvalidModelStateException(int line,
|
InvalidModelStateException::InvalidModelStateException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file)
|
const QByteArray &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
|
@@ -44,10 +44,10 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidPropertyException::InvalidPropertyException(int line,
|
InvalidPropertyException::InvalidPropertyException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &argument)
|
const QByteArray &argument)
|
||||||
: Exception(line, function, file), m_argument(argument)
|
: Exception(line, function, file), m_argument(QString::fromLatin1(argument))
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
}
|
}
|
||||||
|
@@ -44,11 +44,11 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidQmlSourceException::InvalidQmlSourceException(int line,
|
InvalidQmlSourceException::InvalidQmlSourceException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &qmlSource)
|
const QByteArray &qmlSource)
|
||||||
: Exception(line, function, file),
|
: Exception(line, function, file),
|
||||||
m_qmlSource(qmlSource)
|
m_qmlSource(QString::fromUtf8(qmlSource))
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
}
|
}
|
||||||
|
@@ -44,8 +44,8 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidReparentingException::InvalidReparentingException(int line,
|
InvalidReparentingException::InvalidReparentingException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file)
|
const QByteArray &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
|
@@ -45,8 +45,8 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
InvalidSlideIndexException::InvalidSlideIndexException(int line,
|
InvalidSlideIndexException::InvalidSlideIndexException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file)
|
const QByteArray &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
|
@@ -33,8 +33,8 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
NotImplementedException::NotImplementedException(int line,
|
NotImplementedException::NotImplementedException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file):
|
const QByteArray &file):
|
||||||
Exception(line, function, file)
|
Exception(line, function, file)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,8 @@ namespace QmlDesigner {
|
|||||||
the __FILE__ macro.
|
the __FILE__ macro.
|
||||||
*/
|
*/
|
||||||
RemoveBaseStateException::RemoveBaseStateException(int line,
|
RemoveBaseStateException::RemoveBaseStateException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file)
|
const QByteArray &file)
|
||||||
: Exception(line, function, file)
|
: Exception(line, function, file)
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
|
@@ -33,11 +33,11 @@
|
|||||||
using namespace QmlDesigner;
|
using namespace QmlDesigner;
|
||||||
|
|
||||||
RewritingException::RewritingException(int line,
|
RewritingException::RewritingException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &description,
|
const QByteArray &description,
|
||||||
const QString &documentTextContent):
|
const QString &documentTextContent):
|
||||||
Exception(line, function, file), m_description(description), m_documentTextContent(documentTextContent)
|
Exception(line, function, file), m_description(QString::fromLatin1(description)), m_documentTextContent(documentTextContent)
|
||||||
{
|
{
|
||||||
createWarning();
|
createWarning();
|
||||||
}
|
}
|
||||||
|
@@ -42,8 +42,8 @@ class QMLDESIGNERCORE_EXPORT Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Exception(int line,
|
Exception(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
virtual ~Exception();
|
virtual ~Exception();
|
||||||
|
|
||||||
virtual QString type() const = 0;
|
virtual QString type() const = 0;
|
||||||
|
@@ -40,9 +40,9 @@ class QMLDESIGNERCORE_EXPORT InvalidArgumentException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidArgumentException(int line,
|
InvalidArgumentException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &argument);
|
const QByteArray &argument);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
QString argument() const;
|
QString argument() const;
|
||||||
|
@@ -41,16 +41,16 @@ public:
|
|||||||
enum Reason { InvalidCharacters, DuplicateId };
|
enum Reason { InvalidCharacters, DuplicateId };
|
||||||
|
|
||||||
InvalidIdException(int line,
|
InvalidIdException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &id,
|
const QByteArray &id,
|
||||||
Reason reason);
|
Reason reason);
|
||||||
|
|
||||||
InvalidIdException(int line,
|
InvalidIdException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &id,
|
const QByteArray &id,
|
||||||
const QString &description);
|
const QByteArray &description);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
|
@@ -39,8 +39,8 @@ class QMLDESIGNERCORE_EXPORT InvalidMetaInfoException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidMetaInfoException(int line,
|
InvalidMetaInfoException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
|
|
||||||
|
@@ -39,8 +39,8 @@ class QMLDESIGNERCORE_EXPORT InvalidModelNodeException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidModelNodeException(int line,
|
InvalidModelNodeException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
|
|
||||||
|
@@ -39,8 +39,8 @@ class QMLDESIGNERCORE_EXPORT InvalidModelStateException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidModelStateException(int line,
|
InvalidModelStateException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
|
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
|
@@ -39,9 +39,9 @@ class QMLDESIGNERCORE_EXPORT InvalidPropertyException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidPropertyException(int line,
|
InvalidPropertyException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &argument);
|
const QByteArray &argument);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
QString argument() const;
|
QString argument() const;
|
||||||
|
@@ -39,9 +39,9 @@ class QMLDESIGNERCORE_EXPORT InvalidQmlSourceException : public QmlDesigner::Exc
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidQmlSourceException(int line,
|
InvalidQmlSourceException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &qmlSource = QString());
|
const QByteArray &qmlSource = QByteArray());
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
|
@@ -39,8 +39,8 @@ class QMLDESIGNERCORE_EXPORT InvalidReparentingException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidReparentingException(int line,
|
InvalidReparentingException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
};
|
};
|
||||||
|
@@ -39,8 +39,8 @@ class QMLDESIGNERCORE_EXPORT InvalidSlideIndexException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidSlideIndexException(int line,
|
InvalidSlideIndexException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
QString type() const;
|
QString type() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -39,8 +39,8 @@ class QMLDESIGNERCORE_EXPORT NotImplementedException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NotImplementedException(int line,
|
NotImplementedException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
|
|
||||||
|
@@ -39,8 +39,8 @@ class QMLDESIGNERCORE_EXPORT RemoveBaseStateException : public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RemoveBaseStateException(int line,
|
RemoveBaseStateException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file);
|
const QByteArray &file);
|
||||||
|
|
||||||
QString type() const;
|
QString type() const;
|
||||||
|
|
||||||
|
@@ -39,9 +39,9 @@ class QMLDESIGNERCORE_EXPORT RewritingException: public Exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RewritingException(int line,
|
RewritingException(int line,
|
||||||
const QString &function,
|
const QByteArray &function,
|
||||||
const QString &file,
|
const QByteArray &file,
|
||||||
const QString &description,
|
const QByteArray &description,
|
||||||
const QString &documentTextContent);
|
const QString &documentTextContent);
|
||||||
|
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
|
@@ -201,7 +201,7 @@ InternalNode::Pointer ModelPrivate::createNode(const TypeName &typeName,
|
|||||||
bool isRootNode)
|
bool isRootNode)
|
||||||
{
|
{
|
||||||
if (typeName.isEmpty())
|
if (typeName.isEmpty())
|
||||||
throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, tr("invalid type"));
|
throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, tr("invalid type").toLatin1());
|
||||||
|
|
||||||
qint32 internalId = 0;
|
qint32 internalId = 0;
|
||||||
|
|
||||||
@@ -309,8 +309,10 @@ void ModelPrivate::changeNodeId(const InternalNode::Pointer& internalNodePointer
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
notifyNodeIdChanged(internalNodePointer, id, oldId);
|
notifyNodeIdChanged(internalNodePointer, id, oldId);
|
||||||
|
|
||||||
} catch (const RewritingException &e) {
|
} catch (const RewritingException &e) {
|
||||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id, e.description());
|
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id.toLatin1(), e.description().toLatin1());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,9 +323,9 @@ void ModelPrivate::checkPropertyName(const QString &propertyName)
|
|||||||
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<empty property name>");
|
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, "<empty property name>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propertyName == "id") {
|
if (propertyName == QLatin1String("id")) {
|
||||||
Q_ASSERT_X(propertyName != "id", Q_FUNC_INFO, "cannot add property id");
|
Q_ASSERT_X(propertyName != QLatin1String("id"), Q_FUNC_INFO, "cannot add property id");
|
||||||
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, propertyName);
|
throw InvalidPropertyException(__LINE__, __FUNCTION__, __FILE__, propertyName.toLatin1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -821,7 +823,7 @@ void ModelPrivate::resetModelByRewriter(const QString &description)
|
|||||||
if (rewriterView())
|
if (rewriterView())
|
||||||
rewriterView()->resetToLastCorrectQml();
|
rewriterView()->resetToLastCorrectQml();
|
||||||
|
|
||||||
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, description, rewriterView()->textModifierContent());
|
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, description.toLatin1(), rewriterView()->textModifierContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -193,13 +193,13 @@ void ModelNode::setIdWithoutRefactoring(const QString &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isValidId(id))
|
if (!isValidId(id))
|
||||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id, InvalidIdException::InvalidCharacters);
|
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id.toLatin1(), InvalidIdException::InvalidCharacters);
|
||||||
|
|
||||||
if (id == m_internalNode->id())
|
if (id == m_internalNode->id())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (view()->hasId(id))
|
if (view()->hasId(id))
|
||||||
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id, InvalidIdException::DuplicateId);
|
throw InvalidIdException(__LINE__, __FUNCTION__, __FILE__, id.toLatin1(), InvalidIdException::DuplicateId);
|
||||||
|
|
||||||
m_model.data()->d->changeNodeId(internalNode(), id);
|
m_model.data()->d->changeNodeId(internalNode(), id);
|
||||||
}
|
}
|
||||||
|
@@ -537,7 +537,7 @@ void RewriterView::applyChanges()
|
|||||||
qDebug() << "Content:" << content;
|
qDebug() << "Content:" << content;
|
||||||
if (!errors().isEmpty())
|
if (!errors().isEmpty())
|
||||||
qDebug() << "Error:" << errors().first().description();
|
qDebug() << "Error:" << errors().first().description();
|
||||||
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, m_rewritingErrorMessage, content);
|
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, m_rewritingErrorMessage.toLatin1(), content.toLatin1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user