Skip to content

Commit 9b73425

Browse files
committed
#fix #280, (Tailing very large .txt files doesn't work) @harriv please re-test
1 parent 72ef995 commit 9b73425

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

DebugView++/LogView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ void CLogView::OnLButtonDown(UINT flags, CPoint point)
449449

450450
int x0 = GetSubItemRect(info.iItem, info.iSubItem, LVIR_BOUNDS).left + GetHeader().GetBitmapMargin();
451451
auto line = TabsToSpaces(GetItemWText(info.iItem, ColumnToSubItem(Column::Message)));
452-
auto pos = 0;
452+
size_t pos = 0;
453453
int min = 1000 * 1000;
454454
bool found = false;
455455
for (;;)

DebugView++/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#define VERSION 1,7,0,90
2-
#define VERSION_STR "1.7.0.90"
1+
#define VERSION 1,7,0,93
2+
#define VERSION_STR "1.7.0.93"

DebugView++Lib/BinaryFileReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void BinaryFileReader::ReadUntilEof()
9292
int i = 0;
9393
while (std::getline(m_wifstream, line))
9494
{
95-
if ((++i % 100) == 0) m_update();
95+
if ((++i % 1500) == 0) m_update();
9696
AddLine(Str(line));
9797
}
9898
m_update();

DebugView++Lib/FileReader.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ void FileReader::Initialize()
4848
}
4949
}
5050

51+
boost::signals2::connection FileReader::SubscribeToUpdate(UpdateSignal::slot_type slot)
52+
{
53+
return m_update.connect(slot);
54+
}
55+
5156
bool FileReader::AtEnd() const
5257
{
5358
return m_end;
@@ -73,19 +78,22 @@ void FileReader::Notify()
7378
void FileReader::ReadUntilEof()
7479
{
7580
std::string line;
81+
int count = 0;
7682
while (std::getline(m_ifstream, line))
7783
{
84+
m_line += line;
85+
if ((++count % 1500) == 0) m_update();
7886
if (m_ifstream.eof())
7987
{
80-
// the line ended without a newline character, store the line particle
81-
m_line += line;
88+
// the line ended without a newline character
8289
}
8390
else
8491
{
85-
SafeAddLine(m_line + line);
92+
SafeAddLine(m_line);
8693
m_line.clear();
8794
}
8895
}
96+
m_update();
8997

9098
if (m_ifstream.eof())
9199
{

DebugView++Lib/LogSources.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ AnyFileReader* LogSources::AddAnyFileReader(const std::wstring& filename, bool k
362362
}
363363

364364
auto pAnyFileReader = std::make_unique<AnyFileReader>(m_timer, m_linebuffer, filetype, filename, keeptailing);
365+
pAnyFileReader->SubscribeToUpdate([&]() { m_throttledUpdate(); });
365366
auto pResult = pAnyFileReader.get();
366367
Add(std::move(pAnyFileReader));
367368
return pResult;

include/DebugView++Lib/FileReader.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
22
// Distributed under the Boost Software License, Version 1.0.
3-
// (See accompanying file LICENSE_1_0.txt or copy at
3+
// (See accompanying file LICENSE_1_0.txt or copy at
44
// http://www.boost.org/LICENSE_1_0.txt)
55

66
// Repository at: https://github.com/djeedjay/DebugViewPP/
@@ -11,6 +11,7 @@
1111
#include "FileIO.h"
1212
#include "Win32/Win32Lib.h"
1313
#include "DebugView++Lib/LogSource.h"
14+
#include <boost/signals2.hpp>
1415

1516
namespace fusion {
1617
namespace debugviewpp {
@@ -24,7 +25,10 @@ class FileReader : public LogSource
2425
~FileReader() override;
2526

2627
void Initialize() override;
27-
bool AtEnd() const override;
28+
typedef boost::signals2::signal<void()> UpdateSignal;
29+
boost::signals2::connection SubscribeToUpdate(UpdateSignal::slot_type slot);
30+
31+
bool AtEnd() const override;
2832
HANDLE GetHandle() const override;
2933
void Notify() override;
3034
void PreProcess(Line& line) const override;
@@ -36,6 +40,7 @@ class FileReader : public LogSource
3640
FileType::type m_fileType;
3741

3842
private:
43+
3944
void SafeAddLine(const std::string& line);
4045
void ReadUntilEof();
4146

@@ -46,7 +51,8 @@ class FileReader : public LogSource
4651
bool m_initialized;
4752
std::string m_line;
4853
bool m_keeptailing;
54+
UpdateSignal m_update;
4955
};
5056

51-
} // namespace debugviewpp
57+
} // namespace debugviewpp
5258
} // namespace fusion

0 commit comments

Comments
 (0)