multithreading: QThread Unhandled Exception while Executing Boolean

Hello there,

I am getting the error(Standard_ConstructionError at memory location 0x0012b990..) on the BRepAlgoAPI_Common, on the code pasted below:

when I execute BRepAlgoAPI_Common with the same inputs on the main application function it works.
its only when it gets called from the Run function within Qthread that it fails.

I tried other operations like intersecting 2 curves within the QThread->Run function and it works.

I have MMGT_OPT = 0 and REENTRANT = 1
I even have the Standard::SetReentrant(true); on the main function.

Best,

AlexP

// ****************************headerfile

#pragma once

#include
#include

class booleanthread : public QThread
{
Q_OBJECT
public:
booleanthread(QObject *parent = 0,TopoDS_Shape& sh1 = TopoDS_Shape(),TopoDS_Shape& sh2 = TopoDS_Shape())
: QThread(parent),theshape1(sh1),theshape2(sh2)
{
int nullcount = 0;
if(sh1.IsNull()) nullcount++;
if(sh2.IsNull()) nullcount++;

theshape1 = sh1;
theshape2 = sh2;

if(theshape1.IsNull()) nullcount++;
if(theshape2.IsNull()) nullcount++;

inputs

};
~booleanthread(void);

signals:
void finishedshape(TopoDS_Shape);

protected:
void run();

private:

TopoDS_Shape& theshape1;
TopoDS_Shape& theshape2;
QList inputs;

};

//*************** implementation

#include "booleanthread.h"
#include

booleanthread::~booleanthread(void)
{
}

void booleanthread::run()
{

int counter = 0;
if(theshape1.IsNull()) return;
if(theshape2.IsNull()) return;

BRepAlgoAPI_Common* bcom = new BRepAlgoAPI_Common(theshape1,theshape2);

try{ const TopoDS_Shape & result = bcom->Shape();
emit finishedshape(result);
} catch(...) {
int errorstat = bcom->ErrorStatus();
qDebug() }

};

Forum supervisor's picture

Dear AlexP,
Boolean operations are still not thread-safe.
It is a subject for the future work.
Regards

AP's picture

Dear Forum Supervisor,

Thank You.

Best,

AlexP