QmlObserver: Fix 'Apply Changes on Save' on Mac

Use the generic FileInProjectFinder instead of some homebrewn
matching algorithm (which didn't handle the case that on  Mac OS X,
files are copied to the app bundle).

Reviewed-by: Christiaan Janssen
Task-number: QTCREATORBUG-3188
This commit is contained in:
Kai Koehne
2011-04-08 11:54:17 +02:00
parent 26b28804a7
commit 986c9560e9
3 changed files with 4 additions and 38 deletions

View File

@@ -516,16 +516,7 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen
lineNum += rx.cap(3).toInt() - 1; lineNum += rx.cap(3).toInt() - 1;
} }
//convert the filename to a canonical filename in case of shadow build. filename = InspectorUi::instance()->findFileInProject(filename);
bool isShadowBuild = InspectorUi::instance()->isShadowBuildProject();
if (isShadowBuild && rev == 0) {
QString shadowBuildDir = InspectorUi::instance()->debugProjectBuildDirectory();
if (filename.startsWith(shadowBuildDir)) {
ProjectExplorer::Project *debugProject = InspectorUi::instance()->debugProject();
filename = debugProject->projectDirectory() + filename.mid(shadowBuildDir.length());
}
}
// append the debug ids in the hash // append the debug ids in the hash
m_debugIdHash[qMakePair<QString, int>(filename, rev)][qMakePair<int, int>(lineNum, colNum)].append(ref.debugId()); m_debugIdHash[qMakePair<QString, int>(filename, rev)][qMakePair<int, int>(lineNum, colNum)].append(ref.debugId());

View File

@@ -310,13 +310,6 @@ void InspectorUi::connected(ClientProxy *clientProxy)
} }
m_debugProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); m_debugProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject();
if (m_debugProject->activeTarget()
&& m_debugProject->activeTarget()->activeBuildConfiguration())
{
ProjectExplorer::BuildConfiguration *bc
= m_debugProject->activeTarget()->activeBuildConfiguration();
m_debugProjectBuildDir = bc->buildDirectory();
}
connect(m_debugProject, SIGNAL(destroyed()), SLOT(currentDebugProjectRemoved())); connect(m_debugProject, SIGNAL(destroyed()), SLOT(currentDebugProjectRemoved()));
m_projectFinder.setProjectDirectory(m_debugProject->projectDirectory()); m_projectFinder.setProjectDirectory(m_debugProject->projectDirectory());
@@ -787,23 +780,9 @@ InspectorUi *InspectorUi::instance()
return m_instance; return m_instance;
} }
ProjectExplorer::Project *InspectorUi::debugProject() const QString InspectorUi::findFileInProject(const QString &originalPath) const
{ {
return m_debugProject; return m_projectFinder.findFile(originalPath);
}
bool InspectorUi::isShadowBuildProject() const
{
// for .qmlproject based stuff, build dir is empty
if (!debugProject() || debugProjectBuildDirectory().isEmpty())
return false;
return (debugProject()->projectDirectory() != debugProjectBuildDirectory());
}
QString InspectorUi::debugProjectBuildDirectory() const
{
return m_debugProjectBuildDir;
} }
void InspectorUi::setApplyChangesToQmlObserver(bool applyChanges) void InspectorUi::setApplyChangesToQmlObserver(bool applyChanges)

View File

@@ -96,10 +96,7 @@ public:
static InspectorUi *instance(); static InspectorUi *instance();
// returns the project being currently debugged, or 0 if not debugging anything QString findFileInProject(const QString &file) const;
ProjectExplorer::Project *debugProject() const;
QString debugProjectBuildDirectory() const;
bool isShadowBuildProject() const;
void setupUi(); void setupUi();
bool isConnected() const; bool isConnected() const;
@@ -173,7 +170,6 @@ private:
// project is needed for matching filenames, esp. with shadow builds. // project is needed for matching filenames, esp. with shadow builds.
ProjectExplorer::Project *m_debugProject; ProjectExplorer::Project *m_debugProject;
QString m_debugProjectBuildDir;
QStringList m_pendingPreviewDocumentNames; QStringList m_pendingPreviewDocumentNames;
Utils::FileInProjectFinder m_projectFinder; Utils::FileInProjectFinder m_projectFinder;