Skip to content

Commit 9f40cbd

Browse files
authored
Merge pull request #507 from mxaddict/patch-19
Fixed a bug with the errorLogFile causing crashes
2 parents c2855a7 + 5b5e756 commit 9f40cbd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/qt/rpcconsole.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ RPCConsole::RPCConsole(const PlatformStyle *platformStyle, QWidget *parent) :
258258
platformStyle(platformStyle),
259259
peersTableContextMenu(0),
260260
banTableContextMenu(0),
261-
consoleFontSize(0)
261+
consoleFontSize(0),
262+
errorLogFile(0)
262263
{
263264
ui->setupUi(this);
264265
GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this);
@@ -323,11 +324,16 @@ RPCConsole::~RPCConsole()
323324
void RPCConsole::errorLogInitPos()
324325
{
325326
// Check if we already have the file
326-
if (errorLogFile != NULL) {
327+
if (errorLogFile == NULL) {
327328
// Get a QFile instance
328329
errorLogFile = new QFile(QString::fromStdString(GetErrorLogPath().string()));
329330
}
330331

332+
// Check if we have a log file
333+
// We can't tail a missing file
334+
if (!errorLogFile->exists())
335+
return;
336+
331337
// Try to open file
332338
if (!errorLogFile->open(QFile::ReadOnly | QFile::Text))
333339
return;
@@ -374,6 +380,11 @@ void RPCConsole::errorLogRefresh()
374380
if (!errorLogInitPosDone)
375381
errorLogInitPos();
376382

383+
// Check if log initialized
384+
// We can't tail a missing file
385+
if (!errorLogInitPosDone)
386+
return;
387+
377388
// Load the stream
378389
QTextStream in(errorLogFile);
379390

0 commit comments

Comments
 (0)