高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】bb6 problems
bb6 problems
bb6 problems
hallo,
i'll port our source to the new dd with bb6,
at first i tried to make a simple viewer, my problems are:
-i cannot link the wd libs:
[linker error] unresolved external '_errno' referenced from g:\opendwg2006\bb6lib\bb6wd\dd_bb6wd_root.lib|odgd toaimp
the link with the wm ist successful...
what are the difference between the wd and wm libs??
-the second is harder to understand
the reduced sources:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "frmsimple.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
// dwgdirect
#include "odacommon.h"
#include "dbdatabase.h"
// dwgdirect os extensions
#include "exsystemservices.h"
#include "exhostappservices.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "tntbuttons"
#pragma resource "*.dfm"
// link dwgdirect libraries
#pragma link "dd_bb6wm_root.lib"
#pragma link "dd_bb6wm_alloc.lib"
#pragma link "dd_bb6wm_db.lib"
#pragma link "dd_bb6wm_gi.lib"
#pragma link "dd_bb6wm_gs.lib"
#pragma link "dd_bb6wm_ge.lib"
#pragma link "dd_bb6wm_spatialindex.lib"
#pragma link "dd_bb6wm_ft.lib"
//bb stuff
tformsimple *formsimple;
class myservices : public exsystemservices, public exhostappservices
{
public:
void addref() {}
void release() {}
virtual ~myservices()
{
int a = 1;
}
protected:
odrx_using_heap_operators(exsystemservices);
};
myservices odservice;
//---------------------------------------------------------------------------
__fastcall tformsimple::tformsimple(tcomponent* owner)
: tform(owner)
{
odinitialize(&odservice);
}
void __fastcall tformsimple::formdestroy(tobject *sender)
{
oduninitialize();
}
void __fastcall tformsimple::button1click(tobject *sender)
{
oduninitialize();
}
at oduninitialize() in formdestroy() the programm crashes.
i checked, the dtor of myservices, it was'nt called until formdestroy, so
i think the object is valid here. if i comment the call in destroy and do that stuff on the buttonclick, it works.
the error message from the runtime system is: "pure virtual function called"
my opinion: here is a pure virtual funtion from a base-class is called, and the implementaton of the real one was already destroyed.
class
what is wrong here?
is there anything asychronous in oduninitialize()?
ore is global stuff in the libs is destroyed before the call?
the callstack is in the image
attached images
quote:
what are the difference between the wd and wm libs
please, carefully check that the same flags are used. for instance, -twd not -twm, and etc.
this topic was brought up some times here.
also faq should keep some notes concerning bb6.
misha kuzinets
quote:
originally posted by misha kuzinets
please, carefully check that the same flags are used. for instance, -twd not -twm, and etc.
this topic was brought up some times here.
also faq should keep some notes concerning bb6.
hallo misha,
i think the compiler settings are ok there.
if you have got a borland builder, the error is simple reproduceable,
might be that the crash is not a problem of ddwg, i have found that the call of
formdestroy is placed after winmain from the vcl.
its easy to workaround here.
are you shure that the linker error is a settings problem?
please, check this (from faq) :
dwgdirect is throwing exceptions under borland c++ builder or metrowerks codewarrior.
make sure that you are using default data alignment (dwgdirect is built with default alignment on all platforms).
do not use the -b- (makes enums byte-sized when possible) option with the borland compiler. this option introduces errors into dwgdirect with some of our color enums, so it cannot be used (even if dwgdirect is built from source).
in codewarrior, the "enums always int" flag should not be checked, as dwgdirect is not built with this option. enabling this option in client apps will result in misaligned structures, causing unpredictable errors.
misha kuzinets
quote:
originally posted by misha kuzinets
please, check this (from faq) :
dwgdirect is throwing exceptions under borland c++ builder or metrowerks codewarrior.
make sure that you are using default data alignment (dwgdirect is built with default alignment on all platforms).
do not use the -b- (makes enums byte-sized when possible) option with the borland compiler. this option introduces errors into dwgdirect with some of our color enums, so it cannot be used (even if dwgdirect is built from source).
in codewarrior, the "enums always int" flag should not be checked, as dwgdirect is not built with this option. enabling this option in client apps will result in misaligned structures, causing unpredictable errors.
hi misha
the crash is definitively not a result of a false setting "treat enums always int" here, look at the code:
if i call oduninitialize() at buttonclick and not at formdestroy, it works fine.
as i said, may be that the vcl do some special things here.
michael
pure virtual function call occurs if an object's virtual function is called after object is destroyed already. it may happen if some related static objects are being destroyed because the order of destoying static objects is unpredictable.
or it may happen if by the moment oduninitialize is called not all db objects are destroyed (probably smart pointers exist holding them). the order in which things happen must be the following:
1. services object is created.
2. odinitialize() is called.
3. db code working (loading files, creating and modifying db objects, file save etc.
4. all db objects are destroyed. smart pointers must go out of scope or be zeroed to release db objects.
5. oduninitialize() is called.
6. services object is destroyed.
sergey slezkin
|