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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +470,7 @@ void GitPlugin::statusFile()
|
|||||||
|
|
||||||
void GitPlugin::logFile()
|
void GitPlugin::logFile()
|
||||||
{
|
{
|
||||||
const QFileInfo fileInfo = currentFile();
|
const QFileInfo fileInfo = currentFile();
|
||||||
const QString fileName = fileInfo.fileName();
|
const QString fileName = fileInfo.fileName();
|
||||||
const QString workingDirectory = fileInfo.absolutePath();
|
const QString workingDirectory = fileInfo.absolutePath();
|
||||||
m_gitClient->log(workingDirectory, fileName);
|
m_gitClient->log(workingDirectory, fileName);
|
||||||
@@ -631,7 +632,7 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor)
|
|||||||
tr("Do you want to commit the change?"),
|
tr("Do you want to commit the change?"),
|
||||||
tr("The commit message check failed. Do you want to commit the change?"),
|
tr("The commit message check failed. Do you want to commit the change?"),
|
||||||
&settings.promptToSubmit, !m_submitActionTriggered);
|
&settings.promptToSubmit, !m_submitActionTriggered);
|
||||||
m_submitActionTriggered = false;
|
m_submitActionTriggered = false;
|
||||||
switch (answer) {
|
switch (answer) {
|
||||||
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
|
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
|
||||||
return false; // Keep editing and change file
|
return false; // Keep editing and change file
|
||||||
|
Reference in New Issue
Block a user