查看单个帖子
旧 2009-05-05, 09:53 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】establishing the active database

establishing the active database.
establishing the active database.
hello,
this code is copied from the one you use in oninitialupdate in odamfcapp.
my target is to change the file that is shown on the view.
apparently it works fine although if i want the view showing the new file immediately with his correct size, i need a call to onsize or another method that redraws the window.
縒hy this call is not needed in oninitialupdate?.
縄s it safe deleting the old database like i do?
縄s it safe deleting the old device like i do?
void cdwgviewer:nchangedatabase()
{
m_pdevice = null;
pdb = null;
//strfilename is obtained from a dialog box.
pdb = theapp.readfile(strfilename, false, false, oda::ksharedenyno );
odgicontextfordbdatabase::setdatabase(pdb);
if (!pdb.isnull())
{
// begin rendering
odgsdcrect screenrect(odgsdcpoint(0, 0), odgsdcpoint(100, 100));
// create the custom rendering device
odgsdeviceptr pdevice = new odrxobjectimpl<exgssimpledevice>();
exgssimpledevice* pexdevice = (exgssimpledevice*)pdevice.get();
// set the output stream and database for the device.
pexdevice->setattribs(stdout);
pexdevice->setdatabase(pdb);
// prepare the device to render the active layout in this database.
pdevice = oddbgsmanager::setupactivelayoutviews(pdevice, pexdevice);
onoptionsrenderingdevicechanged();
//crect rc;
//getclientrect(rc);
//odgsdcrect outputrect( odgsdcpoint(rc.left, rc.bottom),
// odgsdcpoint(rc.right, rc.top) );
// m_pdevice->onsize(outputrect);
// initiate rendering.
pdevice->update(&screenrect);
// end rendering
redrawwindow();
}
}
best regards.
i believe its safe to
m_pdevice = null;
pdb = null;
since pdb is a smarpointer oddbdatabaseptr which should release and delete.
however, i can't fully answer your questions because i do know know how your classes are defined/derived, where pdb and m_pdevice are defined ect.
i assume that if it works with no leaks or crashing then all is fine
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)