QmlJSObserver: Fix crash when adding an element to some .qml files

Make sure that the 'artifical' URL of the item created actually is
absolute (starts with a file:///). Otherwise an Assert will be hit
when the imports include e.g. a .js file, and the Engine tries to
load it.

Task-number: QTCREATORBUG-2644
Reviewed-by: Olivier Goffart
This commit is contained in:
Kai Koehne
2010-10-07 13:13:05 +02:00
parent 6863a848e9
commit d1175f3ea2
2 changed files with 3 additions and 2 deletions

View File

@@ -363,7 +363,8 @@ void Delta::insert(UiObjectMember *member, UiObjectMember *parentMember, const Q
importList << doc->source().mid(importBegin, importEnd - importBegin); importList << doc->source().mid(importBegin, importEnd - importBegin);
} }
QString filename = doc->fileName() + QLatin1Char('_') + QString::number(doc->editorRevision()) // encode editorRevision, lineNumber in URL. See ClientProxy::buildDebugIdHashRecursive
QString filename = QLatin1String("file://") + doc->fileName() + QLatin1Char('_') + QString::number(doc->editorRevision())
+ QLatin1Char(':') + QString::number(uiObjectDef->firstSourceLocation().startLine-importList.count()); + QLatin1Char(':') + QString::number(uiObjectDef->firstSourceLocation().startLine-importList.count());
foreach(DebugId debugId, debugReferences) { foreach(DebugId debugId, debugReferences) {
if (debugId != -1) { if (debugId != -1) {

View File

@@ -410,7 +410,7 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen
int rev = 0; int rev = 0;
// handle the case where the url contains the revision number encoded. (for object created by the debugger) // handle the case where the url contains the revision number encoded. (for object created by the debugger)
static QRegExp rx("^(.*)_(\\d+):(\\d+)$"); static QRegExp rx("^file://(.*)_(\\d+):(\\d+)$");
if (rx.exactMatch(filename)) { if (rx.exactMatch(filename)) {
filename = rx.cap(1); filename = rx.cap(1);
rev = rx.cap(2).toInt(); rev = rx.cap(2).toInt();