November 25, 2010

zing0000 zing0000
Lab Rat
44 posts

crash in custom widget example

 

I built customwidgetplugin using Qt Creator.

I created a minimum Qt Application (testwidget.vcproj) in VS2008 using the VS2008 add-in.

I opened testwidget.ui in Qt Designer and added the Widget, – object name is analogClock.

Back to VS2008. – I copy analogclock.h into the project directory. – I copy customwidgetplugin dll, lib and pdb into .\Debug directory.

The project builds with no errors or warnings.

I launch testwidget.exe and it finds and loads the plug-in.
But then it crashes at the constructor.

void setupUi(QMainWindow *testwidgetClass) { if (testwidgetClass->objectName().isEmpty()) testwidgetClass->setObjectName(QString::fromUtf8(“testwidgetClass”)); testwidgetClass->resize(450, 316); centralWidget = new QWidget(testwidgetClass); centralWidget->setObjectName(QString::fromUtf8(“centralWidget”)); analogClock = new AnalogClock(centralWidget);

I have not modified or added a single line of code, but clearly I am misusing the tools in some way.

Here is the VS2008 output
‘testwidget.exe’: Loaded ‘D:\Smartience2AV\MeeGo\testwidget\Debug\testwidget.exe’, Symbols loaded.
‘testwidget.exe’: Loaded ‘C:\Windows\System32\ntdll.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\kernel32.dll’
‘testwidget.exe’: Loaded ‘D:\NokiaQt\Qt4.7.1\bin\QtCored4.dll’, Symbols loaded.
‘testwidget.exe’: Loaded ‘C:\Windows\System32\user32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\gdi32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\advapi32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\rpcrt4.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\ole32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\msvcrt.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\ws2_32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\nsi.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_2a4cbfc25558bcd3\msvcp90d.dll’, Symbols loaded.
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_2a4cbfc25558bcd3\msvcr90d.dll’, Symbols loaded.
‘testwidget.exe’: Loaded ‘D:\NokiaQt\Qt4.7.1\bin\QtGuid4.dll’, Symbols loaded.
‘testwidget.exe’: Loaded ‘C:\Windows\System32\comdlg32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\shlwapi.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6001.18523_none_886c608850a2f36f\comctl32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\shell32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\oleaut32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\imm32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\msctf.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\winmm.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\oleacc.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\winspool.drv’
‘testwidget.exe’: Loaded ‘D:\Smartience2AV\MeeGo\testwidget\Debug\customwidgetplugin.dll’, Binary was not built with debug information.
‘testwidget.exe’: Loaded ‘D:\NokiaQt\Qt4.7.1\bin\QtGui4.dll’, Binary was not built with debug information.
‘testwidget.exe’: Loaded ‘D:\NokiaQt\Qt4.7.1\bin\QtCore4.dll’, Binary was not built with debug information.
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2\msvcp90.dll’, Symbols loaded.
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2\msvcr90.dll’, Symbols loaded.
‘testwidget.exe’: Loaded ‘C:\Windows\System32\lpk.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\usp10.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6001.18523_none_5cdd65e20837faf2\comctl32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\uxtheme.dll’
‘testwidget.exe’: Loaded ‘C:\Program Files\SetPoint\lgscroll.dll’, Binary was not built with debug information.
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_d08d7da0442a985d\msvcr80.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_d08d7da0442a985d\msvcp80.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\ntmarta.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\Wldap32.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\psapi.dll’
‘testwidget.exe’: Loaded ‘C:\Windows\System32\samlib.dll’
The program ‘7424 testwidget.exe: Native’ has exited with code 1 (0×1).

Everything looks good until it dies in the constructor. Dependency Walker shows the entry point is there…

9 replies

November 25, 2010

IrQX IrQX
Lab Rat
74 posts

Have you included “widget.h, widget.cpp and widget.ui” files to your project?

November 25, 2010

zing0000 zing0000
Lab Rat
44 posts

Yes, they are. And as the entry point is visible with Dependency Walker, it would appear that everything built correctly.

The problem is that I cannot debug into the DLL because it was not built in VS2008. Can anyone recommend a way forward (or make a divine guess as to the cause of the problem in the first place!)

November 25, 2010

Gerolf Gerolf
Robot Herder
3253 posts

Did you change QtCreator to use the MSVC compiler? Or do you use creator with gcc? If you use it with gcc, it will not work together with a MSVC project.
And as far as I know, plug-ins must be located inside a subdirectory plugins, don’t they?

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 25, 2010

Volker Volker
Ant Farmer
5428 posts
zing0000 wrote:
The problem is that I cannot debug into the DLL because it was not built in VS2008. Can anyone recommend a way forward (or make a divine guess as to the cause of the problem in the first place!)

You cannot mix C++ libs compiled with different versions of Visual Studio. All C++ code must be compiled with VS2008, including the Qt libs (there are prebuild binaries on the downloads page [qt.nokia.com]).

November 25, 2010

Gerolf Gerolf
Robot Herder
3253 posts

You can’t mix if the libs are not memory clean (which means the memory that is allocated inside the lib is also freed in the lib). If it’s memory clean, it is possible. But with using Qt classes, it’s not….

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 25, 2010

Volker Volker
Ant Farmer
5428 posts

Even if they are memory clean, it’s not advisable, because they depend on different major versions of the C++ standard libs (MSVCPxx.DLL). This may cause different behaviour on method/function calls due to different implementations or default values.

November 25, 2010

Gerolf Gerolf
Robot Herder
3253 posts

That is true, but in general it works (we have such stuff here, even I don’t like that). But it only works, if the libs are memory clean. By the way, I didn’t say that I like that :-)

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

November 25, 2010

Volker Volker
Ant Farmer
5428 posts

We all do like the DLL hell together with the new manifest fiasco, don’t we? :-)

November 25, 2010

zing0000 zing0000
Lab Rat
44 posts

Success!

In Qt Creator, Projects tab, Build settings – I was correctly using the Microsoft Visual C++ tool chain BUT I had not selected the Release build.

The docs clearly state you must use a release build in VS2008.

Now it works, and I can debug into the DLL from VS2008.

 
  ‹‹ background image for an application      [solved]shows splashscreen but does not show its message ››

You must log in to post a reply. Not a member yet? Register here!