Forum archiveIssue archiveOther usage issues

Archived discussion

Calling TPrsStd_AISViewer::New(..) causes segfault

Other usage issuesFri, 09/13/2002 - 10:316 replies

Browse this forum
QuestionAuthor

Hello all,

I have trouble displaying anything in an V3d_View. As soon as I call

TPrsStd_AISViewer::New(document->Main(), myViewer);

the app crashes. Unfortunately the debugger has no more information about what methods are called below this level. The libs do not contain any debug info:-(
Does anyone have any idea what I could have done wrong when initializing the TDocStd_Document document?

Regards,

Björn

Discussion

6 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hi,

look if both handles (the document and the viewer) are ok.

regards,

Commenter-1 Müller

02Author

Dear Patrik,

thanks for your reply. For some reason I had commented out the initialization of the Viewer.
However, now the error occurs when calling V3d_View::FitAll() after inserting an object in the OCAF data structure.
As far as I can see, I'm doing almost everything the same way as the Sample apps shipping with OCC4.0 except I have a much cleaner class decomposition:-)

Björn

03Commenter-1

Hi again,

look at this at the sample:

it would be easier for me if you show your initialization.

Commenter-1

04Commenter-1

Written to fast :-))

show me your initialisation. Perhaps it is easier seeing where the problem is.

Commenter-1

05Author

Hi Patrik,

some explanation:

Every document (using my own class here) has a vector of windows containing views and, of course, a Handle(TDocStd_Document) document.
After adding a Box (methods for other objects look just the same) I want to call FitAll on all the views. Currently there's only one view per document, but that will change in the future.
One strange thing is:
A couple of minutes ago I commented out the automatic call to FitAll and everything worked fine when i called FitAll from a different location later.

Maybe you have an idea.

Adding a Box:

void PM_Document_t::createBox(void) {

document->NewCommand();
PadMesh::ShapeDrivers::ShapeCreator_t shapeCreator(document->Main());

TDF_Label L = shapeCreator.createBox(.0, .0, .0, .1, .1, .1);

Handle(TPrsStd_AISPresentation) prs = TPrsStd_AISPresentation::Set(
L, TNaming_NamedShape::GetID());

prs->SetColor(Quantity_NOC_GOLDENROD);
prs->Display(1);

// update all views here
for (vector::iterator p = docWindows->begin();
p != docWindows->end();
p++)
{
int i = 0;
((PM_MDIWindow_t*) p)->fitView();
#ifdef DEBUG
cout << "PM_MDIWindow_t::fit called " << ++i << " times\n";
#endif
}

#ifdef DEBUG
cout << "fitView called on all PM_MDIWindows belonging to this doc\n";
#endif

TDataStd_Integer::Set(L, 1);
myCtx->UpdateCurrentViewer();

document->CommitCommand();

#ifdef DEBUG
printOCAFTree();
#endif
}

Initialization of the view (being called on first paint-Event):

void PM_View_t::init(
void)
{
#ifdef DEBUG
cout << "PM_View_t::init()\n";
#endif

// myView = myCtx->CurrentViewer()->CreateView();
myView = document->getViewer()->CreateView();

int windowHandle = (int) winId();
short hi, lo;
lo = (short) windowHandle;
hi = (short) (windowHandle >> 16);

Handle(Xw_Window) hWnd = new Xw_Window(Handle(Graphic3d_GraphicDevice)::
DownCast(myCtx->CurrentViewer()->
Device()),
(int) hi, (int) lo,
Xw_WQ_3DQUALITY, Quantity_NOC_BLACK);

myView->SetWindow(hWnd);
if (!hWnd->IsMapped()) hWnd->Map();
myView->MustBeResized();
}

06Commenter-1

I do it this way:

for (this->GetViewer()->InitActiveViews();
this->GetViewer()->MoreActiveViews();
this->GetViewer()->NextActiveViews())
{
this->GetViewer()->ActiveView()->FitAll();

GetViewer() gives me the V3d_Viewer handle.

try that in Debug mode and look where it crashes.

HTH,
Commenter-1