need to copy worksheet_ipml before modifying worksheet container, otherwise handle become invalid during realloc

This commit is contained in:
Thomas Fussell 2016-03-08 11:35:22 +08:00
parent b56722ed65
commit ad69dcb335
2 changed files with 4 additions and 2 deletions

View File

@ -39,7 +39,7 @@ public:
xlnt::workbook wb;
auto new_sheet = wb.create_sheet();
wb.add_sheet(new_sheet);
TS_ASSERT(new_sheet.compare(wb[2], false));
TS_ASSERT(wb[1].compare(wb[2], false));
}
// void test_add_sheetname() {} unnecessary

View File

@ -160,7 +160,9 @@ worksheet workbook::create_sheet()
void workbook::add_sheet(xlnt::worksheet worksheet)
{
if(worksheet.d_->parent_ != this) throw xlnt::value_error();
d_->worksheets_.emplace_back(*worksheet.d_);
xlnt::detail::worksheet_impl impl(*worksheet.d_);
*create_sheet().d_ = impl;
}
void workbook::add_sheet(xlnt::worksheet worksheet, std::size_t index)