destuructor外的例外
Exception outside of destructor
本文关键字:destuructor 更新时间:2023-10-16
这是我的破坏者:
CDBColumnInfo::~CDBColumnInfo()
{
m_rowIndexDataMap.clear();
m_colNameList.clear();
m_colNameMap.clear();
}
after脱离近距离,它在功能中抛出了例外
_CRT_SECURITYCRITICAL_ATTRIBUTE
void __CRTDECL operator delete(void* const block) noexcept
{
#ifdef _DEBUG
_free_dbg(block, _UNKNOWN_BLOCK);
#else
free(block);
#endif
}
调试时,我检查了拆卸代码,显示此行中的例外:
00007FFEA4AB8660 call std::map<int,_bstr_t,std::less<int>,std::allocator<std::pair<int const ,_bstr_t> > >::~map<int,_bstr_t,std::less<int>,std::allocator<std::pair<int const ,_bstr_t> > > (07FFEA4A43E7Ch)
我不知道到底发生了什么,但是在我的程序中定义了这样的地图:
//代码更新
std::map<int, _bstr_t> m_rowIndexDataMap; //class variable
HRESULT CDBColumnInfo::AddData()
{
CComPtr<CDBColumnInfo> spResult = new CDBColumnInfo();
map<int,_bstr_t> recordMap ;
_bstr_t record;
for (int rownum = 0; rownum < num_rows; ++rownum){
const int num_cols = PQnfields(res);
record = "";
for (int colnum = 0; colnum < num_cols; ++colnum) {
if (PQgetisnull(res, rownum, colnum) == 0) {
char* data = PQgetvalue(res, rownum, colnum);
record = record + data;
}
else {
record = record + L"<NULL>";
}
if (colnum + 1 < num_cols) {
record = record + "#";
}
}
recordMap[rownum] = record;
}
spResult->SetMap(recordMap);
...
...
}
STDMETHODIMP CDBColumnInfo::SetMap (std::map<int, _bstr_t> dataMap)
{
CComSingleLock lock (m_critSec);
m_rowIndexDataMap = dataMap;
return S_OK;
}
STDMETHODIMP CDBColumnInfo::GetMap (DBrowIndexToDataMap& dataMap)
{
CComSingleLock lock (m_critSec);
dataMap = m_rowIndexDataMap;
return S_OK;
}
CDBColumnInfo::~CDBColumnInfo()
{
m_rowIndexDataMap.clear();
m_colNameList.clear();
m_colNameMap.clear();
}
从驱动器中删除第一个"〜"。应该是
CDBColumnInfo::~CDBColumnInfo()
{
m_rowIndexDataMap.clear();
m_colNameList.clear();
m_colNameMap.clear();
}