File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 5
5
6
6
#include " buffer_table_model.h"
7
7
8
+ #define TABLE_BUFFER_LIMIT (1024 *1024 *1024 )
9
+
8
10
BufferTableModel::BufferTableModel (QObject *parent):
9
11
QAbstractTableModel(parent)
10
12
{
@@ -14,7 +16,13 @@ BufferTableModel::BufferTableModel(QObject *parent):
14
16
15
17
int BufferTableModel::rowCount (const QModelIndex & /* parent*/ ) const
16
18
{
17
- return (state.fileSize + ROW_DATA_SIZE - 1 ) / ROW_DATA_SIZE;
19
+ qint64 tableBufferSize = state.fileSize ;
20
+
21
+ // Limit buffer size to avoid memory overlows for large buffers
22
+ if (tableBufferSize > TABLE_BUFFER_LIMIT)
23
+ tableBufferSize = TABLE_BUFFER_LIMIT;
24
+
25
+ return (tableBufferSize + ROW_DATA_SIZE - 1 ) / ROW_DATA_SIZE;
18
26
}
19
27
20
28
int BufferTableModel::columnCount (const QModelIndex & /* parent*/ ) const
You can’t perform that action at this time.
0 commit comments