Finally I discovered what was causing the issue.
The problem is the way I use QWebView. In my project I have a main application (exe) that creates a QWebView widget. In order to interact with it I connect javaScriptWindowObjectCleared with populateJavaScriptWindowObject
@connect(ui.webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),this, SLOT(populateJavaScriptWindowObject()));
@
In the html side I call my slot using this way
@
a href=""onClick=" javaskript:setCommand('INF');MyEXE.submit()">ELEMENTOS</a>
@
(Note: I deliberate misspelled the <a> & javascript tag in this post to avoid errors in the preview)
So whenever the user clicks in this option my function MyExe.submit() is called in the EXE side.
This function calls a DLL and passes a pointer to the QWebView but before doing that I disconnect the signal in the EXE
@
void MyEXE::submit()
{
...
QLibrary myLib("C:\Users\mahg\Documents\Qt\DLL\debug\DLL_Test2.dll");
typedef int (MyDLL)(Ui::Form, int);
MyDLL myDLL = (MyDLL) myLib.resolve("Dll");
if (myDLL)
{
...
disconnect(ui.webView->page()->mainFrame(),0,0,0);
int i=myDLL(&ui);
...
}
...
}
@
Note: the original code I wrote to disconnect was:
@
disconnect(ui.webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),this, SLOT(populateJavaScriptWindowObject()));
@
Then, the DLL connects the signal javaScriptWindowObjectCleared with its own populateJavaScriptWindowObject and interacts with the user through the QWebView.
So far everything worked fine but there is a problem with the ShouldInterruptJavaScript. This function is triggered if the JavaScript code takes long time, but I discovered that the trigger doesn't occurs in the DLL but in the EXE.
This only occurs if I call the DLL inside the function MyEXE::submit(). If I call it outside this function everything works fine.
I guess Qt can't disconnect theses slots if we are still processing some code inside the slot called from the html
Is this a normal behavior?
I can override the ShouldInterruptJavaScript in the main (EXE) code but this is not fair for me.
If there is no workaround for this I could try to call the DLL outside the MyEXE::submit()