Skip to content

Commit

Permalink
Merge pull request #11783 from daschuer/gh11778
Browse files Browse the repository at this point in the history
Improve debug output for some file system operations
  • Loading branch information
Holzhaus authored Aug 6, 2023
2 parents 00196ea + 47cc029 commit 1ea4c09
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
7 changes: 6 additions & 1 deletion src/engine/sidechain/enginerecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ bool EngineRecord::openFile() {
if (m_pEncoder) {
m_file.setFileName(m_fileName);
if (!m_file.open(QIODevice::WriteOnly)) {
qDebug() << "EngineRecord::openFile() failed for"
<< m_fileName
<< m_file.errorString();
return false;
}
if (m_file.handle() != -1) {
Expand All @@ -330,7 +333,9 @@ bool EngineRecord::openCueFile() {

// TODO(rryan): maybe we need to use the sandbox to get read/write rights on Mac OS ?!
if (!m_cueFile.open(QIODevice::WriteOnly)) {
qDebug() << "Could not write Cue File:" << m_cueFileName;
qDebug() << "Could not write Cue File:"
<< m_cueFileName
<< m_cueFile.errorString();
return false;
}

Expand Down
17 changes: 13 additions & 4 deletions src/library/parsercsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QTextStream>
#include <QtDebug>

#include "errordialoghandler.h"
#include "moc_parsercsv.cpp"

namespace {
Expand Down Expand Up @@ -68,6 +69,10 @@ QList<QString> ParserCsv::parse(const QString& sFilename) {
}
}

qDebug() << "ParserCsv::parse() failed"
<< sFilename
<< file.errorString();

file.close();
return QList<QString>(); //if we get here something went wrong
}
Expand Down Expand Up @@ -127,9 +132,13 @@ bool ParserCsv::writeCSVFile(const QString &file_str, BaseSqlTableModel* pPlayli

QFile file(file_str);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr,
tr("Playlist Export Failed"),
tr("Could not create file") + " " + file_str);
ErrorDialogHandler* pDialogHandler = ErrorDialogHandler::instance();
ErrorDialogProperties* props = pDialogHandler->newDialogProperties();
props->setType(DLG_WARNING);
props->setTitle(tr("Playlist Export Failed"));
props->setText(tr("Could not create file") + " " + file_str);
props->setDetails(file.errorString());
pDialogHandler->requestErrorDialog(props);
return false;
}
//Base folder of file
Expand Down Expand Up @@ -213,7 +222,7 @@ bool ParserCsv::writeReadableTextFile(const QString &file_str, BaseSqlTableModel
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr,
tr("Readable text Export Failed"),
tr("Could not create file") + " " + file_str);
tr("Could not create file") + " " + file_str + +"\n" + file.errorString());
return false;
}

Expand Down
14 changes: 10 additions & 4 deletions src/library/parserm3u.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <QUrl>
#include <QtDebug>

#include "errordialoghandler.h"
#include "moc_parserm3u.cpp"

/**
Expand Down Expand Up @@ -52,7 +53,8 @@ QList<QString> ParserM3u::parse(const QString& sFilename) {
if (!file.open(QIODevice::ReadOnly)) {
qWarning()
<< "Failed to open playlist file"
<< sFilename;
<< sFilename
<< file.errorString();
return m_sLocations;
}

Expand Down Expand Up @@ -146,9 +148,13 @@ bool ParserM3u::writeM3UFile(const QString &file_str, const QList<QString> &item

QFile file(file_str);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr,
tr("Playlist Export Failed"),
tr("Could not create file") + " " + file_str);
ErrorDialogHandler* pDialogHandler = ErrorDialogHandler::instance();
ErrorDialogProperties* props = pDialogHandler->newDialogProperties();
props->setType(DLG_WARNING);
props->setTitle(tr("Playlist Export Failed"));
props->setText(tr("Could not create file") + " " + file_str);
props->setDetails(file.errorString());
pDialogHandler->requestErrorDialog(props);
return false;
}

Expand Down
15 changes: 12 additions & 3 deletions src/library/parserpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <QUrl>
#include <QtDebug>

#include "errordialoghandler.h"
#include "moc_parserpls.cpp"

/**
Expand Down Expand Up @@ -76,6 +77,10 @@ QList<QString> ParserPls::parse(const QString& sFilename) {
}
}

qDebug() << "ParserPls::parse() failed"
<< sFilename
<< file.errorString();

file.close();
return QList<QString>(); //if we get here something went wrong :D
}
Expand Down Expand Up @@ -131,9 +136,13 @@ bool ParserPls::writePLSFile(const QString &file_str, const QList<QString> &item
{
QFile file(file_str);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr,
tr("Playlist Export Failed"),
tr("Could not create file") + " " + file_str);
ErrorDialogHandler* pDialogHandler = ErrorDialogHandler::instance();
ErrorDialogProperties* props = pDialogHandler->newDialogProperties();
props->setType(DLG_WARNING);
props->setTitle(tr("Playlist Export Failed"));
props->setText(tr("Could not create file") + " " + file_str);
props->setDetails(file.errorString());
pDialogHandler->requestErrorDialog(props);
return false;
}
//Base folder of file
Expand Down
5 changes: 4 additions & 1 deletion src/recording/recordingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ void RecordingManager::setRecordingDir() {
if (recordDir.mkpath(recordDir.absolutePath())) {
qDebug() << "Created folder" << recordDir.absolutePath() << "for recordings";
} else {
qDebug() << "Failed to create folder" << recordDir.absolutePath() << "for recordings";
// Using qt_error_string() since QDir has not yet a wrapper for error strings.
// https://bugreports.qt.io/browse/QTBUG-1483
qDebug() << "Failed to create folder" << recordDir.absolutePath()
<< "for recordings:" << qt_error_string();
}
}
m_recordingDir = recordDir.absolutePath();
Expand Down

0 comments on commit 1ea4c09

Please sign in to comment.