mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
divelist: prevent a crash for missing column width
The `static int defaultWidth[]` definition in divelistview.cpp could potentially end up missing an element which can later result in out-of-bounds access when iterating through the list of columns and updating their widths. Add a couple of methods in DiveTripModel for setting and getting the widths and use those. The default values are now pre-set in a QVector in the DiveTripModel() constructor. Throw warnings if out-of-bounds columns are requested. Reported-by: Gaetan Bisson <bisson@archlinux.org> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
53c1c3f26b
commit
e3118d915c
4 changed files with 40 additions and 8 deletions
|
|
@ -94,10 +94,13 @@ public:
|
|||
DiveTripModel(QObject *parent = 0);
|
||||
Layout layout() const;
|
||||
void setLayout(Layout layout);
|
||||
int columnWidth(int column);
|
||||
void setColumnWidth(int column, int width);
|
||||
|
||||
private:
|
||||
void setupModelData();
|
||||
QMap<dive_trip_t *, TripItem *> trips;
|
||||
QVector<int> columnWidthMap;
|
||||
Layout currentLayout;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue