diff --git a/doc/src/qtquick/creator-only/qtquick-buttons.qdoc b/doc/src/qtquick/qtquick-buttons.qdoc similarity index 97% rename from doc/src/qtquick/creator-only/qtquick-buttons.qdoc rename to doc/src/qtquick/qtquick-buttons.qdoc index 00a09a7ccca..0f7c5f5235e 100644 --- a/doc/src/qtquick/creator-only/qtquick-buttons.qdoc +++ b/doc/src/qtquick/qtquick-buttons.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -42,7 +42,11 @@ \list 1 \li Select \uicontrol File > \uicontrol {New File or Project} > + \if defined(qtcreator) \uicontrol Qt > \uicontrol {QML File (Qt Quick 2)} > + \else + \uicontrol {Qt Quick Files} > \uicontrol {Qt Quick File} > + \endif \uicontrol Choose to create a QML file called Button.qml (for example). @@ -147,7 +151,11 @@ \list 1 \li Select \uicontrol File > \uicontrol {New File or Project} > + \if defined(qtcreator) \uicontrol Qt > \uicontrol {QML File (Qt Quick 2)} > + \else + \uicontrol {Qt Quick Files} > \uicontrol {Qt Quick File} > + \endif \uicontrol Choose to create a QML file called Button.qml (for example). diff --git a/doc/src/qtquick/qtquick-components.qdoc b/doc/src/qtquick/qtquick-components.qdoc index 7a83860c722..77e0a8c58a3 100644 --- a/doc/src/qtquick/qtquick-components.qdoc +++ b/doc/src/qtquick/qtquick-components.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -33,11 +33,7 @@ \contentspage index.html \page quick-components.html \previouspage creator-using-qt-quick-designer.html - \if defined(qtdesignstudio) - \nextpage qtquick-navigator.html - \else \nextpage quick-buttons.html - \endif \title Creating Components @@ -466,15 +462,17 @@ Some ready-made controls, such as a gauge, dial, status indicator, and tumbler, are provided by the \l {Qt Quick Extras} module. - \if defined(qtcreator) \section1 Creating Components in Design Mode \list 1 \li Select \uicontrol File > \uicontrol {New File or Project} > - \uicontrol {Files and Classes} > \uicontrol Qt > - \uicontrol {QML File (Qt Quick 2)} > \uicontrol Choose to create a new .qml - file. + \if defined(qtcreator) + \uicontrol Qt > \uicontrol {QML File (Qt Quick 2)} > + \else + \uicontrol {Qt Quick Files} > \uicontrol {Qt Quick File} > + \endif + \uicontrol Choose to create a new .qml file. \note Components are listed in the \uicontrol {QML Components} section of the \uicontrol Library only if the filename begins with a capital @@ -501,7 +499,6 @@ \li \l{Creating Scalable Buttons and Borders} \endlist - \endif \section1 Moving Within Components diff --git a/doc/src/qtquick/qtquick-navigator.qdoc b/doc/src/qtquick/qtquick-navigator.qdoc index e61e517bac9..0215df96bec 100644 --- a/doc/src/qtquick/qtquick-navigator.qdoc +++ b/doc/src/qtquick/qtquick-navigator.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -26,11 +26,7 @@ /*! \contentspage {Qt Creator Manual} \page qtquick-navigator.html - \if defined(qtdesignstudio) - \previouspage quick-components.html - \else \previouspage quick-scalable-image.html - \endif \nextpage qtquick-properties.html \title Managing Item Hierarchy diff --git a/doc/src/qtquick/qtquick-ui-forms.qdoc b/doc/src/qtquick/qtquick-ui-forms.qdoc index 8a320061db4..fe4f7d5ee45 100644 --- a/doc/src/qtquick/qtquick-ui-forms.qdoc +++ b/doc/src/qtquick/qtquick-ui-forms.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -53,8 +53,6 @@ \list \li JavaScript blocks - \li Function definitions - \li Function calls (except \c qsTr) \li Other bindings than pure expressions \li Signal handlers \li States in other items than the root item @@ -74,6 +72,98 @@ \li Transition \endlist + \section1 Supported Methods + + \QC supports most JavaScript functions that are supported by the QML + engine, as well as a subset of Qt QML methods. + + This section lists the functions that you can use in \e .ui.qml files. + + \section2 JavaScript Functions + + As a rule of thumb, \e {pure functions} are supported. They only depend on + and modify states of parameters that are within their scope, and therefore + always return the same results when given the same parameters. This makes + it possible to convert and reformat property bindings without breaking the + \e .ui.qml files. + + The following JavaScript functions are supported: + + \list + \li \c charAt() + \li \c charCodeAt() + \li \c concat() + \li \c endsWith() + \li \c includes() + \li \c indexOf() + \li \c isFinite() + \li \c isNaN() + \li \c lastIndexOf() + \li \c substring() + \li \c toExponential() + \li \c toFixed() + \li \c toLocaleLowerCase() + \li \c toLocaleString + \li \c toLocaleUpperCase() + \li \c toLowerCase() + \li \c toPrecision() + \li \c toString() + \li \c toUpperCase() + \li \c valueOf() + \endlist + + In addition, all functions of the \c Math and \c Date objects are supported. + + For more information, see + \l{https://doc.qt.io/qt-5/qtqml-javascript-functionlist.html} + {List of JavaScript Objects and Functions}. + + \section2 Qt QML Methods + + \QC supports color methods, helper methods for creating objects of + specific data types, and translation methods. + + The following color methods are supported: + + \list + \li \l{Qt::darker()}{Qt.darker()} + \li \l{Qt::hsla()}{Qt.hsla()} + \li \l{Qt::hsva()}{Qt.hsva()} + \li \l{Qt::lighter()}{Qt.lighter()} + \li \l{Qt::rgba()}{Qt.rgba()} + \li \l{Qt::tint()}{Qt.tint()} + \endlist + + The following helper methods are supported: + + \list + \li \l{Qt::formatDate()}{Qt.formatDate()} + \li \l{Qt::formatDateTime()}{Qt.formatDateTime()} + \li \l{Qt::formatTime()}{Qt.formatTime()} + \li \l{Qt::matrix4x4()}{Qt.matrix4x4()} + \li \l{Qt::point()}{Qt.point()} + \li \l{Qt::quaternion()}{Qt.quaternion()} + \li \l{Qt::rect()}{Qt.rect()} + \li \l{Qt::size()}{Qt.size()} + \li \l{Qt::vector2d()}{Qt.vector2d()} + \li \l{Qt::vector3d()}{Qt.vector3d()} + \li \l{Qt::vector4d()}{Qt.vector4d()} + \endlist + + The following translation methods are supported: + + \list + \li \l{Qt::}{qsTr()} + \li \l{Qt::}{qsTranslate()} + \li \l{Qt::}{qsTranslateNoOp()} + \li \l{Qt::}{qsTrId()} + \li \l{Qt::}{qsTrIdNoOp()} + \li \l{Qt::}{qsTrNoOp()} + \endlist + + For more information about using the methods, see + \l{https://doc.qt.io/qt-5/qml-qtqml-qt.html}{Qt QML Methods}. + \section1 Using Qt Quick UI Forms You can edit the forms in the \uicontrol {Form Editor} and diff --git a/share/qtcreator/debugger/cdbbridge.py b/share/qtcreator/debugger/cdbbridge.py index d4aab222bbb..9b1dd07810a 100644 --- a/share/qtcreator/debugger/cdbbridge.py +++ b/share/qtcreator/debugger/cdbbridge.py @@ -507,3 +507,7 @@ class Dumper(DumperBase): def putCallItem(self, name, rettype, value, func, *args): return + + def symbolAddress(self, symbolName): + res = self.nativeParseAndEvaluate(symbolName) + return None if res is None else res.address() diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py index 3eb87f0bb1d..a961569cd03 100644 --- a/share/qtcreator/debugger/lldbbridge.py +++ b/share/qtcreator/debugger/lldbbridge.py @@ -858,16 +858,12 @@ class Dumper(DumperBase): pass self.ignoreStops = 0 - self.silentStops = 0 if platform.system() == 'Linux': if self.startMode_ == AttachCore: pass else: if self.useTerminal_: self.ignoreStops = 2 - else: - self.silentStops = 1 - else: if self.useTerminal_: self.ignoreStops = 1 @@ -878,10 +874,8 @@ class Dumper(DumperBase): if self.sysRoot_: self.debugger.SetCurrentPlatformSDKRoot(self.sysRoot_) - if os.path.isfile(self.executable_): - self.target = self.debugger.CreateTarget(self.executable_, None, None, True, error) - else: - self.target = self.debugger.CreateTarget(None, None, None, True, error) + exefile = None if self.attachPid_ > 0 else self.executable_ + self.target = self.debugger.CreateTarget(exefile, None, None, True, error) if self.nativeMixed: self.interpreterEventBreakpoint = \ @@ -1345,8 +1339,6 @@ class Dumper(DumperBase): elif self.ignoreStops > 0: self.ignoreStops -= 1 self.process.Continue() - elif self.silentStops > 0: - self.silentStops -= 1 else: self.reportState("stopped") else: diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index 7af165a9c6e..3720bdc90a2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -44,6 +44,7 @@ #include #include #include +#include static bool isSimpleExpression(const QString &expression) { @@ -264,11 +265,17 @@ static bool isList(const QQmlProperty &property) return property.propertyTypeCategory() == QQmlProperty::List; } +static bool isQJSValue(const QQmlProperty &property) +{ + return !strcmp(property.propertyTypeName(), "QJSValue"); +} + static bool isObject(const QQmlProperty &property) { - return (property.propertyTypeCategory() == QQmlProperty::Object) || - //QVariant can also store QObjects. Lets trust our model. - (QLatin1String(property.propertyTypeName()) == QLatin1String("QVariant")); + /* QVariant and QJSValue can also store QObjects. Lets trust our model. */ + return (property.propertyTypeCategory() == QQmlProperty::Object + || !strcmp(property.propertyTypeName(), "QVariant") + || isQJSValue(property)); } static QVariant objectToVariant(QObject *object) @@ -337,7 +344,10 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c list.append(object); } else if (isObject(property)) { - property.write(objectToVariant(object)); + if (isQJSValue(property)) /* In this case we have to explcitly generate and convert a QJSValue */ + property.write(QVariant::fromValue(engine()->newQObject(object))); + else + property.write(objectToVariant(object)); if (QQuickItem *item = qobject_cast(object)) if (QQuickItem *newParentItem = qobject_cast(newParent)) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp index 890291f7015..9a5947cdd1b 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard_test.cpp @@ -248,10 +248,10 @@ void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsComboBox() QCOMPARE(qPrintable(disabledComboBox->currentText()), "fgh"); } -static const char *iconInsideResource(const QString &relativePathToIcon) +static QString iconInsideResource(const QString &relativePathToIcon) { const QDir resourcePath(Core::ICore::resourcePath()); - return resourcePath.filePath(relativePathToIcon).toLocal8Bit().data(); + return resourcePath.filePath(relativePathToIcon); } void ProjectExplorer::ProjectExplorerPlugin::testJsonWizardsIconList() diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index 50cd304c9fd..94484f34938 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -914,15 +914,25 @@ void Project::setPreferredKitPredicate(const Kit::Predicate &predicate) } // namespace ProjectExplorer +#include + #include #include namespace ProjectExplorer { -const Utils::FileName TEST_PROJECT_PATH = Utils::FileName::fromString("/tmp/foobar/baz.project"); -const Utils::FileName TEST_PROJECT_NONEXISTING_FILE = Utils::FileName::fromString("/tmp/foobar/nothing.cpp"); -const Utils::FileName TEST_PROJECT_CPP_FILE = Utils::FileName::fromString("/tmp/foobar/main.cpp"); -const Utils::FileName TEST_PROJECT_GENERATED_FILE = Utils::FileName::fromString("/tmp/foobar/generated.foo"); +static Utils::FileName constructTestPath(const char *basePath) +{ + Utils::FileName drive; + if (Utils::HostOsInfo::isWindowsHost()) + drive = Utils::FileName::fromString("C:"); + return drive + QLatin1String(basePath); +} + +const Utils::FileName TEST_PROJECT_PATH = constructTestPath("/tmp/foobar/baz.project"); +const Utils::FileName TEST_PROJECT_NONEXISTING_FILE = constructTestPath("/tmp/foobar/nothing.cpp"); +const Utils::FileName TEST_PROJECT_CPP_FILE = constructTestPath("/tmp/foobar/main.cpp"); +const Utils::FileName TEST_PROJECT_GENERATED_FILE = constructTestPath("/tmp/foobar/generated.foo"); const QString TEST_PROJECT_MIMETYPE = "application/vnd.test.qmakeprofile"; const QString TEST_PROJECT_DISPLAYNAME = "testProjectFoo"; const char TEST_PROJECT_ID[] = "Test.Project.Id"; diff --git a/src/plugins/qmldesigner/designercore/include/rewriterview.h b/src/plugins/qmldesigner/designercore/include/rewriterview.h index c9d2e6dd01c..6a69764dbe8 100644 --- a/src/plugins/qmldesigner/designercore/include/rewriterview.h +++ b/src/plugins/qmldesigner/designercore/include/rewriterview.h @@ -208,6 +208,7 @@ private: //variables bool m_instantQmlTextUpdate = false; std::function m_setWidgetStatusCallback; bool m_hasIncompleteTypeInformation = false; + bool m_restoringAuxData = false; mutable QHash m_canonicalIntModelNode; mutable QHash m_canonicalModelNodeInt; diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 1f977a8199f..40d21beb1a9 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -1519,7 +1519,7 @@ bool NodeMetaInfo::availableInVersion(int majorVersion, int minorVersion) const bool NodeMetaInfo::isSubclassOf(const TypeName &type, int majorVersion, int minorVersion) const { if (!isValid()) { - qWarning() << "NodeMetaInfo is invalid"; + qWarning() << "NodeMetaInfo is invalid" << type; return false; } diff --git a/src/plugins/qmldesigner/designercore/model/abstractview.cpp b/src/plugins/qmldesigner/designercore/model/abstractview.cpp index 73fed323a00..68e11782df6 100644 --- a/src/plugins/qmldesigner/designercore/model/abstractview.cpp +++ b/src/plugins/qmldesigner/designercore/model/abstractview.cpp @@ -591,8 +591,6 @@ void AbstractView::activateTimeline(const ModelNode &timeline) if (currentTimeline().isValid()) currentTimeline().toogleRecording(false); - Internal::WriteLocker locker(m_model.data()); - if (model()) model()->d->notifyCurrentTimelineChanged(timeline); } @@ -615,8 +613,6 @@ void AbstractView::deactivateTimelineRecording() currentTimeline().resetGroupRecording(); } - Internal::WriteLocker locker(m_model.data()); - if (model()) model()->d->notifyCurrentTimelineChanged(ModelNode()); } diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp index 131ffe8fe5c..f4cd9c7e796 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp @@ -392,6 +392,9 @@ void RewriterView::deactivateTextMofifierChangeSignals() void RewriterView::auxiliaryDataChanged(const ModelNode &, const PropertyName &name, const QVariant &) { + if (m_restoringAuxData) + return; + if (name.endsWith("@NodeInstance")) return; @@ -1059,6 +1062,8 @@ void RewriterView::restoreAuxiliaryData() { QTC_ASSERT(m_textModifier, return); + m_restoringAuxData = true; + setupCanonicalHashes(); const QString text = m_textModifier->text(); @@ -1072,6 +1077,8 @@ void RewriterView::restoreAuxiliaryData() QmlJS::SimpleReader reader; checkChildNodes(reader.readFromSource(auxSource), this); } + + m_restoringAuxData = false; } } //QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index 3ed93bb4d74..c2dfea0e73e 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -1733,6 +1733,11 @@ void ModelValidator::typeDiffers(bool /*isRootNode*/, qDebug() << typeName << modelNode.majorVersion() << majorVersion; } + if (modelNode.minorVersion() != minorVersion) { + qDebug() << Q_FUNC_INFO << modelNode; + qDebug() << typeName << modelNode.minorVersion() << minorVersion; + } + QTC_ASSERT(modelNode.majorVersion() == majorVersion, return); QTC_ASSERT(modelNode.minorVersion() == minorVersion, return); QTC_ASSERT(0, return); diff --git a/src/plugins/qtsupport/qtprojectimporter.cpp b/src/plugins/qtsupport/qtprojectimporter.cpp index b9e50017d47..a218ee2b5ec 100644 --- a/src/plugins/qtsupport/qtprojectimporter.cpp +++ b/src/plugins/qtsupport/qtprojectimporter.cpp @@ -601,6 +601,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject() KitManager::deregisterKit(k); // Delete kit templates: + QVERIFY(kitTemplates.removeOne(defaultKit)); qDeleteAll(kitTemplates); } diff --git a/src/plugins/texteditor/completionsettingspage.ui b/src/plugins/texteditor/completionsettingspage.ui index 7eda07d2aed..ce3ba046be3 100644 --- a/src/plugins/texteditor/completionsettingspage.ui +++ b/src/plugins/texteditor/completionsettingspage.ui @@ -101,7 +101,7 @@ - 500 + 2000 50 diff --git a/src/plugins/winrt/winrtpackagedeploymentstep.cpp b/src/plugins/winrt/winrtpackagedeploymentstep.cpp index a7fcb1af5c0..bf681585fa6 100644 --- a/src/plugins/winrt/winrtpackagedeploymentstep.cpp +++ b/src/plugins/winrt/winrtpackagedeploymentstep.cpp @@ -116,8 +116,6 @@ bool WinRtPackageDeploymentStep::init() void WinRtPackageDeploymentStep::run(QFutureInterface &fi) { - AbstractProcessStep::run(fi); - const QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target()->kit()); if (!qt) return; @@ -144,6 +142,8 @@ void WinRtPackageDeploymentStep::run(QFutureInterface &fi) } } } + + AbstractProcessStep::run(fi); } bool WinRtPackageDeploymentStep::processSucceeded(int exitCode, QProcess::ExitStatus status) diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp index 96fb672519c..01233fc46fd 100644 --- a/src/shared/proparser/qmakeevaluator.cpp +++ b/src/shared/proparser/qmakeevaluator.cpp @@ -1185,7 +1185,7 @@ bool QMakeEvaluator::loadSpecInternal() # ifdef Q_OS_UNIX if (m_qmakespec.endsWith(QLatin1String("/default-host")) || m_qmakespec.endsWith(QLatin1String("/default"))) { - QString rspec = QFileInfo(m_qmakespec).readLink(); + QString rspec = QFileInfo(m_qmakespec).symLinkTarget(); if (!rspec.isEmpty()) m_qmakespec = QDir::cleanPath(QDir(m_qmakespec).absoluteFilePath(rspec)); } diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index f41ad66b29d..780fa4ec472 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -1699,6 +1699,8 @@ void tst_Dumpers::dumper() return static_cast(item)->internalName() == iname; })); if (!item) { + if (check.optionallyPresent) + return true; qDebug() << "NOT SEEN: " << check.iname; return false; } diff --git a/tests/system/tools/findUnusedObjects.py b/tests/system/tools/findUnusedObjects.py index a83355ceeb0..09b0064782a 100755 --- a/tests/system/tools/findUnusedObjects.py +++ b/tests/system/tools/findUnusedObjects.py @@ -38,11 +38,13 @@ lastToken = [None, None] stopTokens = ('OP', 'NAME', 'NUMBER', 'ENDMARKER') def parseCommandLine(): - global directory, onlyRemovable, sharedFolders + global directory, onlyRemovable, sharedFolders, deleteObjects parser = OptionParser("\n%prog [OPTIONS] [DIRECTORY]") parser.add_option("-o", "--only-removable", dest="onlyRemovable", action="store_true", default=False, help="list removable objects only") + parser.add_option("-d", "--delete", dest="delete", + action="store_true", default=False) parser.add_option("-s", dest="sharedFolders", action="store", type="string", default="", help="comma-separated list of shared folders") @@ -56,6 +58,7 @@ def parseCommandLine(): parser.print_help() sys.exit(1) onlyRemovable = options.onlyRemovable + deleteObjects = options.delete sharedFolders = map(os.path.abspath, options.sharedFolders.split(',')) def collectObjects(): @@ -153,15 +156,53 @@ def printResult(): print return None -def main(): +def deleteRemovable(): global useCounts, objMap + + deletable = filter(lambda x: useCounts[x] == 0, useCounts) + if len(deletable) == 0: + print("Nothing to delete - leaving objects.map untouched") + return + + data = '' + with open(objMap, "r") as objMapFile: + data = objMapFile.read() + + objMapBackup = objMap + '~' + if os.path.exists(objMapBackup): + os.unlink(objMapBackup) + os.rename(objMap, objMapBackup) + + count = 0 + with open(objMap, "w") as objMapFile: + for line in data.splitlines(): + try: + obj = line.split('\t')[0] + if obj in deletable: + count += 1 + continue + objMapFile.write(line + '\n') + except: + print("Something's wrong in line '%s'" % line) + + print("Deleted %d items, old objects.map has been moved to objects.map~" % count) + return count > 0 + +def main(): + global useCounts, objMap, deleteObjects objMap = checkDirectory(directory) useCounts = dict.fromkeys(collectObjects(), 0) findUsages() atLeastOneRemovable = printResult() + deletedAtLeastOne = deleteObjects and deleteRemovable() + + mssg = None if atLeastOneRemovable: - print "\nAfter removing the listed objects you should re-run this tool" - print "to find objects that might have been used only by these objects.\n" + mssg = "\nAfter removing the listed objects you should re-run this tool\n" + if deletedAtLeastOne: + mssg = "\nYou should re-run this tool\n" + if mssg: + print(mssg + "to find objects that might have been referenced only by removed objects.\n") return 0 if __name__ == '__main__':