高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】what Error Will Cause The Was Open For Write Exception
what error will cause the "was open for write" exception?
what error will cause the "was open for write" exception?
hi,
now i am using the dd2.1.1 for net2003. for some case, when calling oddbdatabase::writefile to write the dwg file, it throws the "was open for write" exception. what error will cause this exception?
any help appreciated.
you might try checking the smart pointer you used.
any smart pointer object that's opened must be released before writing to file.
is there any way let me know which smart pointer is not releaqsed?
is there any way let me know which smart pointer is not released before writing file?
oderror::description() may help you to find out object id of opened object (but not a smart pointer in your programm).
sergey slezkin
if i call the detach() on some smart pointers, then there is no the "was open for write" exception. but i found that in some case i need call this function, in other cases i should not call it, or it will cause other issues.
is there any better way to fix it?
any help appreciated
by the moment you call writefile() you should have no smart pointers pointing to database (which is to written to file) objects except the pointer to the database.
detach() is wrong method to use.
you should call
pointer = 0;
or
pointer.release() // !! not pointer->release()
or if you your pointers go put of scope it's safe too.
{
oddbobjectptr pobj;
.....
}
// here you can safely call writefile()
sergey slezkin
thanks for your reply.
actually, i always use smart pointer in my application for any oddb... object.
now if i call the release function on the smart pointer, it will throw an "invalid input" exception.
so, how can i know which input is invalid when the release function is called on the dim style record smart pointer?
is "invalid input" exception thrown at the moment you release smart pointer or at the moment you call writefile()?
the pointer is to dimstyle table record or dimension?
sergey slezkin
"invalid input" exception thrown at the moment i released the smart pointer to the dimstyle table record.
any suggestions?
what's the contents of call stack at the moment exception is thrown?
sergey slezkin
there is an assert in the release of the dimstyle table record smart point. please refer to the attached invalidinput.jpg.
when thrown the "invalid input" exception, the call stack is as following:
msvcr71d.dll!_assert(const char * expr=0x0886d4b8, const char * filename=0x0886d480, unsigned int lineno=24) ?295 c
dd_root.dll!086cf088()
dd_root.dll!086cf108()
dd_ge.dll!087fad40()
dd_ge.dll!087cfe70()
dd_ge.dll!0885fe67()
recomputedimblock.drx!14a38800()
attached images (22.7 kb, 4 views)
without debug info in stack (function names, line numbers) i only can say that:
at the moment you close the dimension style record blocks for dimension entities referencing this dimstyle are recomputed.
most likely some dimension entity referencing this style has invalid geometry. block recomputing fails while attempting to normalize some vector or trying to calculate normal to a plane.
to determine which dimension entity is incorrect you can try:
1. create dimension style and release its smart pointer.
2. create dimension entities for this style and release their smart pointers.
you'll get the exception releasing smart pointer for the offending dimension entity.
most probably the defect will be obvious like coincident points which must differ.
sergey slezkin
|