![]() |
【转帖】oddbdatabaseinser
oddbdatabase::insert
oddbdatabase::insert hi i want to insert several drawings into one target drawing. the code looks like: code: odstaticrxobject<myservices> *svcs = new odstaticrxobject<myservices>(); odinitialize(svcs); ... // created this and already added some entities oddbdatabaseptr targetdb = ...; // srcfiles is an array containing all (3 in this simple case) src file names for (int i=0; i<3; i++) { oddbdatabaseptr srcdb = svcs->readfile(srcfiles[i]); targetdb->insert(/* some block name */, srcdb); } odwrfilebuf filebuffer(targetfilename); targetdb->writefile(&filebuffer, oddb::kdwg, oddb::vac18); oduninitialize(); the writefile call fails with a "zugriffsverletzung-leseposition 0x013659d4" (freely translated 'accessviolation-address'). below is the stack trace. code: tbdwgbuilder.dll!odobjectdwgoutstream::wrsoftpointerid() + 0x16 c++ tbdwgbuilder.dll!oddbobject::dwgoutfields() + 0x13c c++ tbdwgbuilder.dll!oddbentity::dwgoutfields() + 0x2b c++ tbdwgbuilder.dll!oddbline::dwgoutfields() + 0x35 c++ tbdwgbuilder.dll!oddwgstream::wrbool() + 0x67 c++ tbdwgbuilder.dll!oddwgwriter::saveobject() + 0x383 c++ tbdwgbuilder.dll!oddwgwriter::wrobjects() + 0xd7 c++ tbdwgbuilder.dll!oddwgr18filewriter::wrobjects() + 0xf5 c++ tbdwgbuilder.dll!oddwgr18filewriter::writedatabase() + 0xb7 c++ tbdwgbuilder.dll!oddbdatabase::writefile() + 0x5eb c++ i did a very simple application that inserts one dwg into a target dwg and this simple example worked. so it might be that nothing is wrong with the code. what else could be wrong? do i miss to initialize everything properly? i'm using visual studio .net 2003 on windows xp, just in case that this matters. ??? simon oddbdatabase:insert problem (additional information) ok, i created a simple test program (see below) that fails with the described exception (see my last post). can anybody tell me what's wrong with the code? another interesting point: if i omit the for loop it works!!! i'm sure i'm just missing something. any help? simon code: #include "odacommon.h" #include "dbdatabase.h" #include "tables.h" #include "entities.h" #include "objects.h" #include "rxobjectimpl.h" #include "exsystemservices.h" #include "exhostappservices.h" #include "odfilebuf.h" using namespace std; class myservices : public exsystemservices, public exhostappservices { protected: using exsystemservices::operator new; using exsystemservices::operator delete; }; int _tmain(int argc, _tchar* argv[]) { odrxobjectimpl<myservices> svcs; odinitialize(&svcs); oddbdatabaseptr psrcdb = svcs.createdatabase(); if (argc > 1) { { oddblayertableptr players = psrcdb->getlayertableid().safeopenobject(oddb::kforwrite); oddblayertablerecordptr player = oddblayertablerecord::createobject(); player->setname(odstring("test")); players->add(player); } for (int i=1; i<argc; i++) { odstring blockname; blockname.format("%i", i); oddbdatabaseptr pdb = svcs.readfile(argv[i], false, false); psrcdb->insert(blockname, pdb, true); } odwrfilebuf fb("out.dwg"); psrcdb->writefile(&fb, oddb::kdwg, oddb::vac18); } psrcdb.release(); oduninitialize(); return 0; } hi, the code seems ok. i tested on vs6, win2000 (i don not think that .net is the cause). what version of ddt do you use? if it is the last one, could you send me a file that produces crash? best regards, sergey hi, i have the same problem. what is ddt? dwgdirect toolkit regards, sergey vishnevetsky |
所有的时间均为北京时间。 现在的时间是 02:50 AM. |