QT Sample crashed at myView->SetWindow (hWnd);


I just switched  to Qt5.5.0 and OCC6.9.1

I tried to start the Qt example, given at samples directory:

The application start, but if the View is created, it crashed at the following lines:

  if ( myView.IsNull() )
    myView = myContext->CurrentViewer()->CreateView();

  Aspect_Handle aWindowHandle = (Aspect_Handle ) winId();
  Handle(WNT_Window) hWnd = new WNT_Window (aWindowHandle);

myView->SetWindow (hWnd);

After this line I got an exception, the cursor is placed at heapFree

Whats goining wrong here?

Forum supervisor's picture

Dear Andreas,

I suggest you to check OCCT Mantis issue 26603 (http://tracker.dev.opencascade.org/view.php?id=26603).

The patch for #26603 also includes correction for the crash.

Best regards


Andreas Hirtreiter's picture

Dear Supervisor,

thank you very much for response. May I ask how to get and install that patch?

Forum supervisor's picture

Dear rasmus,

You can download it via the Development portal (see http://dev.opencascade.org/index.php?q=home/get_involved).

First you should register on this site. Branch will be CR26603 (prefix - CR and the issue number - 26603).

Just take into account that this fix applicable to the current development version (i.e. future OCCT7.0.0).

Best regards


Jayden Shui's picture

I met the same problem. I cannot follow the above suggestion. How to fix it on OCCT 6.9.1?

Mohamed El-Haddad's picture


I have tested with both 6.9.1 and 7.0.0 and I get the same exception at View->SetWindow().

The reply above mentions a patch that's been included in 7 to fix this bug, but I can confirm that it's still there.

Here is my stack trace:

1    RaiseException    KERNELBASE        0x756040f8    
2    _CxxThrowException    VCRUNTIME140        0x5eae4995    
3    Standard_Failure::Throw    TKernel        0x58360a06    
4    Standard_Failure::Raise    TKernel        0x583607b2    
5    Graphic3d_ShaderProgram::ShadersFolder    TKV3d        0x57a7e705    
6    OpenGl_ShaderProgram::Initialize    TKOpenGl        0x57e05556    
7    OpenGl_ShaderManager::Create    TKOpenGl        0x57dff6e3    
8    OpenGl_ShaderManager::prepareStdProgramFboBlit    TKOpenGl        0x57e018ea    
9    OpenGl_View::Print    TKOpenGl        0x57dcd1f8    
10    OpenGl_View::redrawImmediate    TKOpenGl        0x57dcf77c    
11    OpenGl_View::Redraw    TKOpenGl        0x57dcda01    
12    V3d_View::Redraw    TKV3d        0x57a5536c    
13    V3d_Viewer::SetViewOn    TKV3d        0x57a60177    
14    V3d_View::SetWindow    TKV3d        0x57a59101    
15    OccView::OccView    OccView.cpp    87    0xec48b3    
16    occQt::occQt    occQt.cpp    59    0xeb80b3    
17    main    main.cpp    20    0xeb32b2    
18    WinMain    qtmain_win.cpp    113    0xec9f1d    
19    invoke_main    exe_common.inl    109    0xec8a3e    
20    __scrt_common_main_seh    exe_common.inl    264    0xec888a    

Forum supervisor's picture

Dear Mohamed,

Your problem occurs at the same method call but actually unrelated to the bug discussed in this thread.

The raised exception indicates that application  didn't initialize the environment variables to mandatory resources (CSF_ShadersDirectory

in this case).

Please make sure you are running sample in designed way (using batch scripts defining environment variables).

The environment variables used by Open CASCADE Technology are described in the corresponding OCCT  documentation.

Best regards


Mohamed El-Haddad's picture

Thank you! That was my problem indeed.

Mohamed El-Haddad's picture

Sorry I have another license-related question now, if I'm distributing my binaries with dynamic linking to occt, I should sitll include the shaders directory with the software package for the viewers to work, correct? In that case, what are my obligations in terms of licensing? Or is there something else that could be done in that case?

Forum supervisor's picture

Dear Mohamed,

OCCT version 6.7.0 and later are governed by GNU LGPL version 2.1 with additional Open CASCADE exception:


You can find the answers on licensing related questions here:


Please, contact us for any additional information.

Best regards,


Wencheng Pan's picture

Title: View->SetWindow() lead to Debug error

Hi, officer

I successfully debug the program last night. However, when I tried to do it again today, firstly, the program required the related .dll. After I setup the correct path to .dll files, the program just Debug Error. I finally locate the Error code as View->SetWindow(). How can I deal with this issue? Thanks