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. QPrinter - Free Heap Block crash
Forum Updated to NodeBB v4.3 + New Features

QPrinter - Free Heap Block crash

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 384 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.
  • M Offline
    M Offline
    MHMart_asc
    wrote on last edited by
    #1

    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 freed

    Since 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;
    }
    

    PrinterTest.pro:

    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
    
    
    JonBJ 1 Reply Last reply
    0
    • M MHMart_asc

      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 freed

      Since 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;
      }
      

      PrinterTest.pro:

      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
      
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @MHMart_asc
      Comment out ui->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.]

      M 1 Reply Last reply
      0
      • JonBJ JonB

        @MHMart_asc
        Comment out ui->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.]

        M Offline
        M Offline
        MHMart_asc
        wrote on last edited by
        #3

        @JonB Thank you for your suggestion!
        Unfortunately, no effect here. The build run still crashes.

        JonBJ 1 Reply Last reply
        0
        • M MHMart_asc

          @JonB Thank you for your suggestion!
          Unfortunately, no effect here. The build run still crashes.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @MHMart_asc
          That is "good", in that it implicates the QPrinter rather than anything else you might have.
          I don't have a solution, you will have to await someone else.

          1 Reply Last reply
          0

          • Login

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