QPrinter - Free Heap Block crash
-
I created a net QT Widget project with Desktop Qt 6.7.0 MSVC2019 64 bit, using Qt Creator on windows.
The sole purpose was testing something with QPrinter so there is only one line added that initiated a QPrinter object.
Once launching or debugging it crashes with:
HEAP[PrinterTest.exe]:
HEAP: Free Heap block 000002054F445C30 modified at 000002054F445C8C after it was freedSince this is a new project, I have no clue how to solve the issue, or what might be its cause?
Could it be a bug?I only altered two files in the new project which are provided down below.
mainwindow.cpp:
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QPrinter> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QPrinter printer(QPrinter::HighResolution); } MainWindow::~MainWindow() { delete ui; }QT += core gui QT += printsupport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -
I created a net QT Widget project with Desktop Qt 6.7.0 MSVC2019 64 bit, using Qt Creator on windows.
The sole purpose was testing something with QPrinter so there is only one line added that initiated a QPrinter object.
Once launching or debugging it crashes with:
HEAP[PrinterTest.exe]:
HEAP: Free Heap block 000002054F445C30 modified at 000002054F445C8C after it was freedSince this is a new project, I have no clue how to solve the issue, or what might be its cause?
Could it be a bug?I only altered two files in the new project which are provided down below.
mainwindow.cpp:
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QPrinter> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QPrinter printer(QPrinter::HighResolution); } MainWindow::~MainWindow() { delete ui; }QT += core gui QT += printsupport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target@MHMart_asc
Comment outui->setupUi(this);. Does it still crash? I realise you will get no visible windows so you will have to kill the process, but I'm picking the simplest change :) [Actually I think you will get a blank main window which you can close.] -
@MHMart_asc
Comment outui->setupUi(this);. Does it still crash? I realise you will get no visible windows so you will have to kill the process, but I'm picking the simplest change :) [Actually I think you will get a blank main window which you can close.]@JonB Thank you for your suggestion!
Unfortunately, no effect here. The build run still crashes. -
@JonB Thank you for your suggestion!
Unfortunately, no effect here. The build run still crashes.@MHMart_asc
That is "good", in that it implicates theQPrinterrather than anything else you might have.
I don't have a solution, you will have to await someone else.