Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Crash in custom widget example
Forum Updated to NodeBB v4.3 + New Features

Crash in custom widget example

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 7.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zing0000
    wrote on 25 Nov 2010, 01:21 last edited by
    #1

    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 (0x1).

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

    1 Reply Last reply
    0
    • I Offline
      I Offline
      IrQX
      wrote on 25 Nov 2010, 04:36 last edited by
      #2

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

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zing0000
        wrote on 25 Nov 2010, 05:17 last edited by
        #3

        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!)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on 25 Nov 2010, 07:55 last edited by
          #4

          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?

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

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on 25 Nov 2010, 13:35 last edited by
            #5

            [quote author="zing0000" date="1290662221"]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!)
            [/quote]

            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":http://qt.nokia.com/downloads).

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on 25 Nov 2010, 14:28 last edited by
              #6

              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....

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

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on 25 Nov 2010, 14:32 last edited by
                #7

                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.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on 25 Nov 2010, 16:40 last edited by
                  #8

                  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 :-)

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

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on 25 Nov 2010, 16:43 last edited by
                    #9

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

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      zing0000
                      wrote on 25 Nov 2010, 18:26 last edited by
                      #10

                      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.

                      1 Reply Last reply
                      0

                      1/10

                      25 Nov 2010, 01:21

                      • Login

                      • Login or register to search.
                      1 out of 10
                      • First post
                        1/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved