简体   繁体   中英

QDialog crash while trying to setText() of QLineEdit right after setupUi()

After the initialization of one Qt dialog returns the pointer to the private data of one QLineEdit gets set to 0. While being inside the generated setupUi() of the dialog the pointer is still valid. Afterwards the structure of this particular QLineEdit seems to be corrupted.

The application crashes both when running inside debugger and without debugger.

Single-threaded application.

QtCreator 2.7.0.

CMake project.

MinGW 20120426 with g++ 4.6.2 (32 Bit application):

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)

Windows 7 64Bit.

The other QLineEdit 'kundenbestellcodeLineEdit' shown at the bottom of 'Locals and Expressions' looks fine.

Q: has anyone experienced this, too, and knows why this happens?

I have some other Usecases with other dialogs which just run fine - so why only this single one creates problems?

I can reproduce this with a Release build on Linux Debian Wheezy with g++ 4.7.2.

New information: I have a second QDialog with the same name 'Dialog_Auswahl_des_Geraetemodells' residing in a different Usecase directory (filesystem) and also a different namespace. When removing this second dialog from link phase the crash does not occur.

Further information: if I rename the second dialog class then the crash does no longer occur. I have verified the linker symbols to be sure that the dialog object files (Dialog_ .o, moc_Dialog_ .o) provide the expected symbols. I have also verified that the Usecase path can be seen inside the moc_*.cxx files.

Since this problem only occurrs at runtime one has to assume that the Qt object system has a problem with identically named classes in different folders/namespaces.

As already stated: the workround is to rename one of those classes.

显示损坏的d指针

A generic answer is that you should run qmake and then build your project, so that you compile updated generated code for your ui file.

If that doesn't solve the issue, i think you should update the question with more information about what you did to get into that situation, and maybe someone will be able to give a better advice, like is the lineedit added later than the rest of the widgets?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM