MSVC debug build doesn't work
-
I built Qt following instructions from here using MSVS Community 2017 and the newest version of Qt from git repository. My configure command was "configure -prefix “f:\Programs\Qt\Qt5.9_MSVC” -developer-build -opensource -confirm-license -nomake examples -nomake tests -opengl desktop -debug-and-release -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -sql-sqlite -sql-odbc -make libs".
Now I have a little test project (Qt Widgets Application) which works in a release build but have a “debug assertion failed” error in a debug build:
File: minkernel\crts\ucrt\appcrt\heap\debug_heap.cpp
Line: 904
Expression: CrtlsValidHeapPointer(block)
Also there is a compiler warning:
“cl.exe” is used by qmake, but “” is configured in the kit.
Please update your kit or choose a mkspec for qmake that matches your target environment better.
These problems don't arise with a kit using MinGW compiler. What is wrong? -
Looks like a bug or undefined behavior in your test project. The fact it works in release mode doesn't mean it really works. Maybe it just silently overwrites some memory but it doesn't have immediate effects that you can see.
Anyway - it's hard to say without looking at the code or at least a call stack. Post it if you can.By the way - if you're not gonna modify Qt itself don't use
-developer-build
. It's bigger, slower and you don't need it for normal development of your apps. It also installs automatically in the build directory so the-prefix
option you used is incompatible with it. Maybe that's what triggers the warning. Or your kit is just misconfigured - again hard to say without seeing. Post a screenshot of your kit properties page if you can. -
The code is simple:
//mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include <QPushButton> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->pushButton, &QPushButton::clicked, ui->label, [this]() { ui->label->setText("Hello, World!"); }); } MainWindow::~MainWindow() { delete ui; }
The form was built in "design" mode. All other code is automatically generated.
Thank you for your note about -developer-build. I'll try to configure building without this option
-
The code is simple:
//mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include <QPushButton> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->pushButton, &QPushButton::clicked, ui->label, [this]() { ui->label->setText("Hello, World!"); }); } MainWindow::~MainWindow() { delete ui; }
The form was built in "design" mode. All other code is automatically generated.
Thank you for your note about -developer-build. I'll try to configure building without this option
@Sylhat said in MSVC debug build doesn't work:
connect(ui->pushButton, &QPushButton::clicked, ui->label, [this]() { ui->label->setText("Hello, World!"); });
Why do you have ui->label in connect() if you use a lambda?
-
@Sylhat said in MSVC debug build doesn't work:
connect(ui->pushButton, &QPushButton::clicked, ui->label, [this]() { ui->label->setText("Hello, World!"); });
Why do you have ui->label in connect() if you use a lambda?
-
@jsulm said in MSVC debug build doesn't work:
Why do you have ui->label in connect() if you use a lambda?
Yes, it's redundant, thank you.
@Sylhat said in MSVC debug build doesn't work:
@jsulm said in MSVC debug build doesn't work:
Why do you have ui->label in connect() if you use a lambda?
Yes, it's redundant, thank you.
No it's not,
it connects the lambda to the existence of the label. If you delete your label, than the connect gets undon.Without it, you get a segfault crash, when you press the QPushButton, when the label does not exist.