Ошибка при использовании клоненода QDomNode

Я использую Qt 4.8.4 и Qt-Creator 3.5.1
Для воспроизведения ошибки необходимо простое окно с одной кнопкой (Crash_btn).

Запустите приложение.

  1. Завершение с кнопкой закрытия (х) все в порядке.
  2. Завершение с кнопкой и ее функцией произойдет сбой.

Я не понимаю, что не так.

#include "mainwindow.h"#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);

//Creating Doc
QDomDocument Doc;
QDomElement Brick = Doc.createElement( "Brick" );
QDomElement Ex = Doc.createElement( "ExtraData" );
Doc.appendChild( Brick );
Brick.appendChild( Ex );

// Reading Doc
QDomNode Node = Brick.firstChildElement( "ExtraData" ).cloneNode(true);
m_ExtraData = new QDomElement( Node.toElement() );

// Using the following two lines, there seem to be no crashes.
//QDomElement Ex2 = Brick.firstChildElement( "ExtraData" );
//*m_ExtraData = Ex2;    // -> The data of the copy is shared (shallow copy)

m_ExtraData->setAttribute( "Message_Text", "Der Text");
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_Crash_btn_clicked()
{
QDomElement XData;
// Each of the two following lines alone  cause a crash
m_ExtraData->setAttribute( "Message_Text", "Der Text");
XData = m_ExtraData->cloneNode( true ).toElement();
qApp->quit();
}

Файл проекта:

QT       += core gui
QT       += xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = D_Setup
TEMPLATE = app

SOURCES += main.cpp\
mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector