Changed JS log file save function so that it doesn't truncate the current temp file.
This commit is contained in:
parent
a929eda845
commit
7b9829eda9
|
@ -2561,11 +2561,21 @@ void QScriptDialog_t::saveLog(bool openFileBrowser)
|
|||
}
|
||||
printf("Saving Log File: %s\n", logSavePath.toLocal8Bit().data());
|
||||
FCEU_WRAPPER_LOCK();
|
||||
flushLog();
|
||||
if ( logFile->copy( logSavePath ) )
|
||||
{
|
||||
// Log file needs to be reopened on a successful copy
|
||||
logFile->reopen();
|
||||
char buffer[4096];
|
||||
flushLog();
|
||||
QFile saveFile( logSavePath );
|
||||
if (saveFile.open(QIODeviceBase::ReadWrite))
|
||||
{
|
||||
logFile->seek(0);
|
||||
qint64 bytesRead = logFile->read(buffer, sizeof(buffer));
|
||||
while (bytesRead > 0)
|
||||
{
|
||||
saveFile.write(buffer, bytesRead);
|
||||
|
||||
bytesRead = logFile->read(buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
FCEU_WRAPPER_UNLOCK();
|
||||
}
|
||||
|
@ -2957,7 +2967,7 @@ void QScriptDialog_t::resetLog()
|
|||
delete logFile;
|
||||
logFile = nullptr;
|
||||
}
|
||||
logFile = new QScriptLogFile(this);
|
||||
logFile = new QTemporaryFile(this);
|
||||
logFile->setAutoRemove(true);
|
||||
logFile->setFileTemplate(QDir::tempPath() + QString("/fceux_js_XXXXXX.log"));
|
||||
logFile->open();
|
||||
|
|
|
@ -726,24 +726,6 @@ public:
|
|||
QMap<QString, JsPropertyItem*> childMap;
|
||||
};
|
||||
|
||||
class QScriptLogFile : public QTemporaryFile
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QScriptLogFile(QObject* parent = nullptr)
|
||||
: QTemporaryFile(parent)
|
||||
{
|
||||
}
|
||||
|
||||
~QScriptLogFile(void){}
|
||||
|
||||
void reopen()
|
||||
{
|
||||
open(QIODeviceBase::Append | QIODeviceBase::ReadWrite);
|
||||
}
|
||||
};
|
||||
|
||||
class QScriptDialog_t : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -764,7 +746,7 @@ protected:
|
|||
QMenuBar* buildMenuBar();
|
||||
|
||||
QMenuBar* menuBar;
|
||||
QScriptLogFile *logFile = nullptr;
|
||||
QTemporaryFile *logFile = nullptr;
|
||||
QTimer *periodicTimer;
|
||||
QLineEdit *scriptPath;
|
||||
QLineEdit *scriptArgs;
|
||||
|
|
Loading…
Reference in New Issue