equal
deleted
inserted
replaced
407 if (importType == QDeclarativeScriptParser::Import::File && qmldircomponents.isEmpty()) { |
407 if (importType == QDeclarativeScriptParser::Import::File && qmldircomponents.isEmpty()) { |
408 QUrl importUrl = base.resolved(QUrl(uri + QLatin1String("/qmldir"))); |
408 QUrl importUrl = base.resolved(QUrl(uri + QLatin1String("/qmldir"))); |
409 QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl); |
409 QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl); |
410 if (!localFileOrQrc.isEmpty()) { |
410 if (!localFileOrQrc.isEmpty()) { |
411 QString dir = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))); |
411 QString dir = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))); |
412 if (dir.isEmpty() || !QDir().exists(dir)) { |
412 QFileInfo dirinfo(dir); |
|
413 if (dir.isEmpty() || !dirinfo.exists() || !dirinfo.isDir()) { |
413 if (errorString) |
414 if (errorString) |
414 *errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri_arg); |
415 *errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri_arg); |
415 return false; // local import dirs must exist |
416 return false; // local import dirs must exist |
416 } |
417 } |
417 uri = resolvedUri(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))), database); |
418 uri = resolvedUri(QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))), database); |
423 } |
424 } |
424 } else { |
425 } else { |
425 if (prefix.isEmpty()) { |
426 if (prefix.isEmpty()) { |
426 // directory must at least exist for valid import |
427 // directory must at least exist for valid import |
427 QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))); |
428 QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri))); |
428 if (localFileOrQrc.isEmpty() || !QDir().exists(localFileOrQrc)) { |
429 QFileInfo dirinfo(localFileOrQrc); |
|
430 if (localFileOrQrc.isEmpty() || !dirinfo.exists() || !dirinfo.isDir()) { |
429 if (errorString) { |
431 if (errorString) { |
430 if (localFileOrQrc.isEmpty()) |
432 if (localFileOrQrc.isEmpty()) |
431 *errorString = QDeclarativeImportDatabase::tr("import \"%1\" has no qmldir and no namespace").arg(uri); |
433 *errorString = QDeclarativeImportDatabase::tr("import \"%1\" has no qmldir and no namespace").arg(uri); |
432 else |
434 else |
433 *errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri); |
435 *errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri); |
443 url.chop(1); |
445 url.chop(1); |
444 } |
446 } |
445 |
447 |
446 if (vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) { |
448 if (vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) { |
447 QList<QDeclarativeDirParser::Component>::ConstIterator it = qmldircomponents.begin(); |
449 QList<QDeclarativeDirParser::Component>::ConstIterator it = qmldircomponents.begin(); |
|
450 int lowest_maj = INT_MAX; |
|
451 int lowest_min = INT_MAX; |
|
452 int highest_maj = INT_MIN; |
|
453 int highest_min = INT_MIN; |
448 for (; it != qmldircomponents.end(); ++it) { |
454 for (; it != qmldircomponents.end(); ++it) { |
449 if (it->majorVersion > vmaj || (it->majorVersion == vmaj && it->minorVersion >= vmin)) |
455 if (it->majorVersion > highest_maj || (it->majorVersion == highest_maj && it->minorVersion > highest_min)) { |
450 break; |
456 highest_maj = it->majorVersion; |
451 } |
457 highest_min = it->minorVersion; |
452 if (it == qmldircomponents.end()) { |
458 } |
|
459 if (it->majorVersion < lowest_maj || (it->majorVersion == lowest_maj && it->minorVersion < lowest_min)) { |
|
460 lowest_maj = it->majorVersion; |
|
461 lowest_min = it->minorVersion; |
|
462 } |
|
463 } |
|
464 if (lowest_maj > vmaj || (lowest_maj == vmaj && lowest_min > vmin) |
|
465 || highest_maj < vmaj || (highest_maj == vmaj && highest_min < vmin)) |
|
466 { |
453 *errorString = QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin); |
467 *errorString = QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin); |
454 return false; |
468 return false; |
455 } |
469 } |
456 } |
470 } |
457 |
471 |
821 { |
835 { |
822 if (qmlImportTrace()) |
836 if (qmlImportTrace()) |
823 qDebug() << "QDeclarativeImportDatabase::addPluginPath" << path; |
837 qDebug() << "QDeclarativeImportDatabase::addPluginPath" << path; |
824 |
838 |
825 QUrl url = QUrl(path); |
839 QUrl url = QUrl(path); |
826 if (url.isRelative() || url.scheme() == QString::fromLocal8Bit("file")) { |
840 if (url.isRelative() || url.scheme() == QLatin1String("file")) { |
827 QDir dir = QDir(path); |
841 QDir dir = QDir(path); |
828 filePluginPath.prepend(dir.canonicalPath()); |
842 filePluginPath.prepend(dir.canonicalPath()); |
829 } else { |
843 } else { |
830 filePluginPath.prepend(path); |
844 filePluginPath.prepend(path); |
831 } |
845 } |
840 return; |
854 return; |
841 |
855 |
842 QUrl url = QUrl(path); |
856 QUrl url = QUrl(path); |
843 QString cPath; |
857 QString cPath; |
844 |
858 |
845 if (url.isRelative() || url.scheme() == QString::fromLocal8Bit("file")) { |
859 if (url.isRelative() || url.scheme() == QLatin1String("file")) { |
846 QDir dir = QDir(path); |
860 QDir dir = QDir(path); |
847 cPath = dir.canonicalPath(); |
861 cPath = dir.canonicalPath(); |
848 } else { |
862 } else { |
849 cPath = path; |
863 cPath = path; |
850 } |
864 } |