diff options
author | George Hazan <ghazan@miranda.im> | 2020-05-10 12:55:27 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-05-10 12:55:27 +0300 |
commit | 5e132354765fc28b5fe6ca3121be30fc4b5aed04 (patch) | |
tree | c94e525f5e76ba1d8900fb74a3d7eec9c905bbab /plugins/NewStory/src | |
parent | 17895ec37e6e958d9dec963484091f38a3329443 (diff) |
fix for occasional crash
Diffstat (limited to 'plugins/NewStory/src')
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index df39a0ef0f..7c55e309e9 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -195,7 +195,6 @@ HistoryArray::HistoryArray() : pages(50), strings(50, wcscmp) { - pages.insert(new ItemBlock()); } HistoryArray::~HistoryArray() @@ -268,6 +267,8 @@ ItemData& HistoryArray::allocateItem() pages.insert(new ItemBlock()); iLastPageCounter = 0; } + else if (pages.getCount() == 0) + pages.insert(new ItemBlock); auto &p = pages[pages.getCount() - 1]; return p.data[iLastPageCounter++]; @@ -287,5 +288,6 @@ ItemData* HistoryArray::get(int id, bool bLoad) int HistoryArray::getCount() const { - return (pages.getCount() - 1) * HIST_BLOCK_SIZE + iLastPageCounter; + int nPages = pages.getCount(); + return (nPages == 0) ? 0 : (nPages - 1) * HIST_BLOCK_SIZE + iLastPageCounter; } |