forked from qt-creator/qt-creator
Fixed warnings about absolutePath on empty filename in git plugin
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
@@ -427,30 +427,31 @@ void GitPlugin::diffCurrentProject()
|
|||||||
|
|
||||||
QFileInfo GitPlugin::currentFile() const
|
QFileInfo GitPlugin::currentFile() const
|
||||||
{
|
{
|
||||||
QString fileName = m_core->fileManager()->currentFile();
|
return QFileInfo(m_core->fileManager()->currentFile());
|
||||||
QFileInfo fileInfo(fileName);
|
|
||||||
return fileInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitPlugin::getWorkingDirectory()
|
QString GitPlugin::getWorkingDirectory()
|
||||||
{
|
{
|
||||||
QString workingDirectory;
|
QString workingDirectory;
|
||||||
if (const ProjectExplorer::ProjectExplorerPlugin *p = ProjectExplorer::ProjectExplorerPlugin::instance())
|
if (const ProjectExplorer::ProjectExplorerPlugin *p = ProjectExplorer::ProjectExplorerPlugin::instance()) {
|
||||||
if (p && p->currentNode())
|
if (p && p->currentNode()) {
|
||||||
workingDirectory = QFileInfo(p->currentNode()->path()).absolutePath();
|
const QString currentPath = p->currentNode()->path();
|
||||||
|
if (!currentPath.isEmpty())
|
||||||
|
workingDirectory = QFileInfo(currentPath).absolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Git::Constants::debug > 1)
|
if (Git::Constants::debug > 1)
|
||||||
qDebug() << Q_FUNC_INFO << "Project" << workingDirectory;
|
qDebug() << Q_FUNC_INFO << "Project" << workingDirectory;
|
||||||
|
|
||||||
if (workingDirectory.isEmpty())
|
if (workingDirectory.isEmpty()) {
|
||||||
workingDirectory = QFileInfo(m_core->fileManager()->currentFile()).absolutePath();
|
const QString currentFileName = m_core->fileManager()->currentFile();
|
||||||
|
if (!currentFileName.isEmpty())
|
||||||
|
workingDirectory = QFileInfo(currentFileName).absolutePath();
|
||||||
|
}
|
||||||
if (Git::Constants::debug > 1)
|
if (Git::Constants::debug > 1)
|
||||||
qDebug() << Q_FUNC_INFO << "file" << workingDirectory;
|
qDebug() << Q_FUNC_INFO << "file" << workingDirectory;
|
||||||
|
|
||||||
if (workingDirectory.isEmpty()) {
|
|
||||||
VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Could not find working directory"));
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
return workingDirectory;
|
return workingDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user