ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

xml loading failure in On_kInitAppMsg

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
leonimas
874 Views, 8 Replies

xml loading failure in On_kInitAppMsg

Hi to all,

 

i must load a xml file inside On_kInitAppMsg(); I use QT, particulary QXmlSchema.

The source code is very simple:

 

.....

  schema = new QXmlSchema;
  schema->setMessageHandler(msgHandler);
 

  if (schema->load(QUrl::fromLocalFile(xsdFilename))) {
    result = schema->isValid();
  }

.....

 

when the system executes the 'load' method, the arx loading inside autocad seems go

in loop ... the load fun doesn't return ...

 

I've put my source code under the comment  '// TODO: Add your initialization code here'

 

Why ? If I execute te code out of the On_kInitAppMsg() for example inside an autocad

command, the code works

 

Best Regards

Leonard

 

8 REPLIES 8
Message 2 of 9
maisoui
in reply to: leonimas

Hi,

 

Maybe you don't have a valid QCoreApplication? When you talks about loop, it means that application stucks on line schema->load...?

I guess app loading is not the better solution to do long process (like getting data from the Internet), you should execute your code in document loading/activating.

 

Regards,

--
Jonathan
Message 3 of 9
leonimas
in reply to: maisoui

Hi,

yesterday I've done qt source debug and the QT 'load' fun stucks

in module qacceltreeresourceloader.cpp, method:

 

networkLoop.exec(QEventLoop::ExcludeUserInputEvents)

 

precisely at:

 

    if (networkLoop.exec(QEventLoop::ExcludeUserInputEvents))
    {
        const QString errorMessage(escape(reply->errorString()));

        /* Note, we delete reply before we exit this function with error(). */
        delete reply;

        const QSourceLocation location(uri);

        if(context && (errorHandling == FailOnError))
            context->error(errorMessage, ReportContext::FODC0002, location);

        return 0;
    }

    ....

 

Many Thanks

Leonard

 

Message 4 of 9
maisoui
in reply to: leonimas

It seems you haven't a valid Qt main loop. Did you initialize/create a QApplication?

--
Jonathan
Message 5 of 9
leonimas
in reply to: maisoui

No,

I don't have a QApplication istance, my code is:

 

virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt)

{
        // TODO: Load dependencies here

        // You *must* call On_kInitAppMsg here
        AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
        
        // TODO: Add your initialization code here
        PathTreeXmlScanner xmlScan;
        gModel = xmlScan.load(xmlPath);

        return (retCode) ;

}

 

where 'PathTreeXmlScanner' is a my custom class that use QT ...

How I can use QApplication ? If I write:

 

app.execute();

 

the execution flow stucks ....

 

Best Regards

Leonard

Message 6 of 9
maisoui
in reply to: leonimas

It's necessary to create a valid QApplicatoin. (no need to call app.execute(), cause acad.exe is the main process). You just need to create a QApplication.

Have a look to : http://doc.qt.digia.com/solutions/4/qtwinmigrate/qmfcapp.html.

Regards,

--
Jonathan
Message 7 of 9
leonimas
in reply to: maisoui

Hello Jonathan,

 

😞 doesn't works ... I've modified the code as follow:

 

QApplication app();
PathTreeXmlScanner xmlScan;
gModel = xmlScan.load(xmlPath);

 

Regard

Leonard

 

 

 

Message 8 of 9
maisoui
in reply to: leonimas

QApplication needs to exist as long your ARX is loaded. So use pointer:

 

int argc = 0;
(void)new QApplication(argc, 0);

 

If you use Qt5, I notice, you need to call once qApp->processEvents(). (don't no why, I'm on the way to migrate from Qt 4.8.5 to Qt 5.2)

Regards,

--
Jonathan
Message 9 of 9
leonimas
in reply to: maisoui

Hi Jonathan,

 

🙂 works ! Thank you very much ... If possible I've another strange

problem ObjectArx-Qt ... I've posted it some times ago but I don't

received solution 😞

 

// --------------------------------------------------------------------------------------------------

I want create a thumbnails dialog with QT, to show a dwg file (one or more dwgs); I've

writed the following codes:

 

HWND acadHandle = adsw_acadMainWnd();
QWinWidget win(acadHandle);
symPreviewDiag diag(&win); // the QT dialog

 

::EnableWindow (acadHandle, true);
::smileyfrustrated:etFocus (acadHandle);


diag.setWindowModality(Qt::WindowModality::ApplicationModal);

diag.show();
QPlatformNativeInterface* inter = QGuiApplication::smileytongue:latformNativeInterface();

QWindow* w=diag.windowHandle(); // is NOT equal to 0
HWND h = static_cast<HWND>(inter->nativeResourceForWindow(QByteArrayLiteral("handle"), w)); // is NOT equal to 0


bool b = false;
b = acdbDisplayPreviewFromDwg(result->resval.rstring, h, (Adesk::UInt32 *)RGB(255,0,255)); // the b value is 'true'
diag.update();

(void) a.exec();

 

I see the qt dialog but i don't see the dwg files ... :smileysad: !

Must I use a QWidget child of QTDialog ?

Which type of QWidget ?

/ -------------------------------------------------------------------------------------------------------------------------------------

 

Regards

Leonard

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost