Fixed warnings about absolutePath on empty filename in git plugin

Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Thorbjørn Lindeijer
2010-01-06 19:12:19 +01:00
parent cce26703ae
commit fdbdf50ce4

View File

@@ -427,30 +427,31 @@ void GitPlugin::diffCurrentProject()
QFileInfo GitPlugin::currentFile() const
{
QString fileName = m_core->fileManager()->currentFile();
QFileInfo fileInfo(fileName);
return fileInfo;
return QFileInfo(m_core->fileManager()->currentFile());
}
QString GitPlugin::getWorkingDirectory()
{
QString workingDirectory;
if (const ProjectExplorer::ProjectExplorerPlugin *p = ProjectExplorer::ProjectExplorerPlugin::instance())
if (p && p->currentNode())
workingDirectory = QFileInfo(p->currentNode()->path()).absolutePath();
if (const ProjectExplorer::ProjectExplorerPlugin *p = ProjectExplorer::ProjectExplorerPlugin::instance()) {
if (p && p->currentNode()) {
const QString currentPath = p->currentNode()->path();
if (!currentPath.isEmpty())
workingDirectory = QFileInfo(currentPath).absolutePath();
}
}
if (Git::Constants::debug > 1)
qDebug() << Q_FUNC_INFO << "Project" << workingDirectory;
if (workingDirectory.isEmpty())
workingDirectory = QFileInfo(m_core->fileManager()->currentFile()).absolutePath();
if (workingDirectory.isEmpty()) {
const QString currentFileName = m_core->fileManager()->currentFile();
if (!currentFileName.isEmpty())
workingDirectory = QFileInfo(currentFileName).absolutePath();
}
if (Git::Constants::debug > 1)
qDebug() << Q_FUNC_INFO << "file" << workingDirectory;
if (workingDirectory.isEmpty()) {
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Could not find working directory"));
return QString();
}
return workingDirectory;
}