PDA

View Full Version : how to solve the bug:the inferior stopped because it received a singal from ...



wter27
7th January 2011, 08:19
I use a dialog to call the mainwindow,but it appear the bug: the inferior stopped because it received a singal from ....I don't know why.because if i only debug the ui_mainwindow with the main.cpp,it is very normal .But once I use anther dialog to call the mainwindow , it appears
.Someone think maybe it is the pointer's problem .so how to fix it .please,thanks.
the full bug is :
the inferior stopped because it received a singal from oprating system,
signal name:sigsegv
signal meaning:segmentation fault.

ui_mainwindow.h file content:

/************************************************** ******************************
** Form generated from reading UI file 'gkxt2uW4872.ui'
**
** Created: Fri Dec 31 12:17:38 2010
** by: Qt User Interface Compiler version 4.7.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
************************************************** ******************************/

#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtGui/QScrollArea>
#include <QtGui/QScrollBar>
#include <QtGui/QStatusBar>
#include <QtGui/QWidget>

QT_BEGIN_NAMESPACE

class Ui_m_window
{
public:
QAction *menu_start;
QAction *menu_exit;
QAction *action_3;
QAction *action_5;
QAction *action_6;
QAction *menu_sysset;
QAction *menu_queset;
QAction *menu_login;
QAction *menu_bbs;
QAction *menu_learn;
QAction *action_12;
QAction *action_14;
QWidget *centralWidget;
QScrollArea *scrollArea;
QWidget *scrollAreaWidgetContents;
QPushButton *pBut_up;
QPushButton *pBut_next;
QRadioButton *rBut_ans_a;
QRadioButton *rBut_ans_b;
QRadioButton *rBut_ans_c;
QRadioButton *rBut_ans_d;
QScrollArea *scrollArea_2;
QWidget *scrollAreaWidgetContents_2;
QScrollBar *verticalScrollBar;
QLabel *label_hint;
QLabel *label_time;
QMenuBar *menuBar;
QMenu *menu_file;
QMenu *menu_tool;
QMenu *menu_set;
QMenu *menu_help;
QStatusBar *statusBar;

void setupUi(QMainWindow *m_window)
{
if (m_window->objectName().isEmpty())
m_window->setObjectName(QString::fromUtf8("m_window"));
m_window->setEnabled(true);
m_window->resize(650, 420);
m_window->setMinimumSize(QSize(650, 420));
m_window->setMaximumSize(QSize(650, 420));
/*
menu_start = new QAction(m_window);//the line which is wrong with something i dont know
menu_start->setObjectName(QString::fromUtf8("menu_start"));
menu_start->setAutoRepeat(false);
menu_exit = new QAction(m_window);
menu_exit->setObjectName(QString::fromUtf8("menu_exit"));

action_3 = new QAction(m_window);
action_3->setObjectName(QString::fromUtf8("action_3"));
action_5 = new QAction(m_window);
action_5->setObjectName(QString::fromUtf8("action_5"));
action_6 = new QAction(m_window);
action_6->setObjectName(QString::fromUtf8("action_6"));
menu_sysset = new QAction(m_window);
menu_sysset->setObjectName(QString::fromUtf8("menu_sysset"));
menu_queset = new QAction(m_window);
menu_queset->setObjectName(QString::fromUtf8("menu_queset"));
menu_login = new QAction(m_window);
menu_login->setObjectName(QString::fromUtf8("menu_login"));
menu_bbs = new QAction(m_window);
menu_bbs->setObjectName(QString::fromUtf8("menu_bbs"));
menu_learn = new QAction(m_window);
menu_learn->setObjectName(QString::fromUtf8("menu_learn"));
……………some code …………………à ¢â‚¬Â¦Ã¢â‚¬Â¦Ã¢â‚¬Â¦Ã¢â‚¬Â¦Ã¢â‚¬Â¦Ã¢â‚¬Â¦Ã¢â‚¬Â¦
statusBar->setObjectName(QString::fromUtf8("statusBar"));
m_window->setStatusBar(statusBar);

menuBar->addAction(menu_file->menuAction());
menuBar->addAction(menu_tool->menuAction());
menuBar->addAction(menu_set->menuAction());
menuBar->addAction(menu_help->menuAction());
menu_file->addAction(menu_start);
menu_file->addAction(menu_exit);
menu_tool->addAction(menu_login);
menu_tool->addAction(menu_bbs);
menu_tool->addAction(menu_learn);
menu_tool->addSeparator();
menu_tool->addAction(action_12);
menu_tool->addAction(action_14);
menu_set->addAction(menu_sysset);
menu_set->addAction(menu_queset);
menu_help->addAction(action_3);
menu_help->addAction(action_5);
menu_help->addAction(action_6);
*/
retranslateUi(m_window);


QMetaObject::connectSlotsByName(m_window);
} // setupUi

void retranslateUi(QMainWindow *m_window)
{
m_window->setWindowTitle(QApplication::translate("m_window", "\350\200\203\350\257\225\346\265\213\350\257\225\3 47\263\273\347\273\237", 0, QApplication::UnicodeUTF8));
menu_start->setText(QApplication::translate("m_window", "\345\274\200\345\247\213\346\265\213\350\257\225", 0, QApplication::UnicodeUTF8));
menu_exit->setText(QApplication::translate("m_window", "\351\200\200\345\207\272", 0, QApplication::UnicodeUTF8));
action_3->setText(QApplication::translate("m_window", "\346\263\250\345\206\214", 0, QApplication::UnicodeUTF8));
action_5->setText(QApplication::translate("m_window", "\344\275\277\347\224\250\350\257\264\346\230\216", 0, QApplication::UnicodeUTF8));
action_6->setText(QApplication::translate("m_window", "\347\211\210\346\235\203", 0, QApplication::UnicodeUTF8));
menu_sysset->setText(QApplication::translate("m_window", "\347\263\273\347\273\237\350\256\276\347\275\256", 0, QApplication::UnicodeUTF8));
menu_queset->setText(QApplication::translate("m_window", "\351\242\230\345\272\223\350\256\276\347\275\256", 0, QApplication::UnicodeUTF8));
menu_login->setText(QApplication::translate("m_window", "\347\231\273\351\231\206\347\263\273\347\273\237", 0, QApplication::UnicodeUTF8));
menu_bbs->setText(QApplication::translate("m_window", "\350\256\277\351\227\256\350\256\272\345\235\233", 0, QApplication::UnicodeUTF8));
menu_learn->setText(QApplication::translate("m_window", "\345\234\250\347\272\277\345\255\246\344\271\240", 0, QApplication::UnicodeUTF8));
action_12->setText(QApplication::translate("m_window", "\350\256\260\345\277\206\345\212\233\346\265\213\3 50\257\225", 0, QApplication::UnicodeUTF8));
action_14->setText(QApplication::translate("m_window", "\346\216\250\347\220\206\346\265\213\350\257\225", 0, QApplication::UnicodeUTF8));
pBut_up->setText(QApplication::translate("m_window", "\344\270\212\344\270\200\351\242\230\347\233\256", 0, QApplication::UnicodeUTF8));
pBut_next->setText(QApplication::translate("m_window", "\344\270\213\344\270\200\351\242\230\347\233\256", 0, QApplication::UnicodeUTF8));
rBut_ans_a->setText(QApplication::translate("m_window", "A", 0, QApplication::UnicodeUTF8));
rBut_ans_b->setText(QApplication::translate("m_window", "B", 0, QApplication::UnicodeUTF8));
rBut_ans_c->setText(QApplication::translate("m_window", "C", 0, QApplication::UnicodeUTF8));
rBut_ans_d->setText(QApplication::translate("m_window", "D", 0, QApplication::UnicodeUTF8));
label_hint->setText(QApplication::translate("m_window", "\351\200\211\346\213\251\347\255\224\346\241\210", 0, QApplication::UnicodeUTF8));
label_time->setText(QApplication::translate("m_window", "____________", 0, QApplication::UnicodeUTF8));
menu_file->setTitle(QApplication::translate("m_window", "\346\226\207\344\273\266", 0, QApplication::UnicodeUTF8));
menu_tool->setTitle(QApplication::translate("m_window", "\345\267\245\345\205\267", 0, QApplication::UnicodeUTF8));
menu_set->setTitle(QApplication::translate("m_window", "\350\256\276\347\275\256", 0, QApplication::UnicodeUTF8));
menu_help->setTitle(QApplication::translate("m_window", "\345\270\256\345\212\251", 0, QApplication::UnicodeUTF8));
} // retranslateUi

};

namespace Ui {
class m_window: public Ui_m_window {};
} // namespace Ui

QT_END_NAMESPACE

#endif // 5GKXT2UW4872_H

Lykurg
7th January 2011, 08:44
Please note that we have [code] tags here. Further it is most unlikely that something inside the Qt generated ui-cpp file crashes. So please show us, how you use the ui file in the application. Also try to debug and see what the backtrace is saying.

MarekR22
7th January 2011, 08:44
Cant you read, comments in this file?

/************************************************** ******************************
** Form generated from reading UI file 'gkxt2uW4872.ui'
**
** Created: Fri Dec 31 12:17:38 2010
** by: Qt User Interface Compiler version 4.7.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
************************************************** ******************************/
This is auto generated file. So this file where error in YOUR code cause critical error. So actual error happened sooner somewhere deeper in you code.

Run you app in debug mode from IDE. When it crushes, go to IDE window called "Call Stack". Find first file from top with YOUR code (code you have written). Click this entry in "Call stack" window.
Check values of variables, pointer and so and try find the reason of this crush.

wysota
7th January 2011, 12:28
Just by looking at what you commented out you can see that you don't create many of the objects that you later refer to from within retranslateUi().

wter27
9th January 2011, 08:33
what do you mean ?create many of the objects that you later refer to from within retranslateUi(). ?
When I debug the program file,I found that there are some tips about the win@16.My OS is windows xp sp3/NT4.0,I also installed the visual studio c++ 6.0.
The target of the main program compiled by the QT may be the WINCE,because I found the var of Q_WINCE .Do I need to move on to the GNU/Linux or just reinstall the QT and some *.h files?

wysota
9th January 2011, 09:32
I mean that you commented out some code which is needed for another part of the code to work. This is basic C++ you know...

wter27
9th January 2011, 10:23
if i dont commented the code.the debug will say that:the inferior stopped...
if i commented them ,there would be no bugs and run normally.
so what's the reason?

Lykurg
9th January 2011, 10:28
Please make a minimal compilable example reproducing your problem.

wter27
9th January 2011, 12:49
my program was qt-sdk-win-opensource-2010.05,the os is windows xp sp3;
my program contains :
1.main.cpp
2.dialog_login.cpp
3.dialog_login.h
4.ui_dialog_login.h
5.temp.cpp
6.temp.h
7.ui_temp.h
when i run the program and push the cancel button of dialog ,here debug comes the resualt:

the inferior stopped beacause it recieved a signal of operating system.;
signal name:SIGSEGV;
signal meaning:segmentation fault;
here's the code:

main.cpp file content:


#include <QtGui>
#include <QtGui/QApplication>
#include "dialog_login.h"
#include "temp.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
dialog_login login_box;
login_box.show();
if(login_box.exec()==QDialog::Rejected)//
{
MainWindow mainwindow;
mainwindow.show();
}
return app.exec();
}


dialog_login.cpp file content:


#include "dialog_login.h"
dialog_login:: dialog_login(QDialog *parent)
: QDialog(parent)
{
ui2->setupUi(this);
}
dialog_login::~dialog_login()
{
delete ui2;
}


dialog_login.h file content:

#ifndef DIALOG_LOGIN_H
#define DIALOG_LOGIN_H

#include <QtGui/QDialog>
#include "ui_dialog_login.h"
class dialog_login : public QDialog
{
Q_OBJECT
public:
explicit dialog_login(QDialog *parent = 0);
~dialog_login();
private:
Ui2::dialog_login *ui2;
};
#endif // DIALOG_LOGIN_H



ui_dialog_login.h file content:



#ifndef DIALOG_LOGINGK4464_H
#define DIALOG_LOGINGK4464_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QCheckBox>
#include <QtGui/QDialog>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtWebKit/QWebView>

QT_BEGIN_NAMESPACE

class Ui_dialog_login
{
public:
QLineEdit *lineEdit_username;
QLineEdit *lineEdit_password;
QLabel *label;
QLabel *label_2;
QPushButton *pushButton_login;
QPushButton *pushButton_cancel;
QCheckBox *checkBox_remberpass;
QCheckBox *checkBox_loginauto;
QWebView *webView_ad_login;
QWebView *webView_register;
QWebView *webView_getpassword;

void setupUi(QDialog *dialog_login)
{
if (dialog_login->objectName().isEmpty())
dialog_login->setObjectName(QString::fromUtf8("dialog_login"));
dialog_login->resize(393, 229);
dialog_login->setMinimumSize(QSize(393, 229));
dialog_login->setMaximumSize(QSize(393, 229));
label = new QLabel(dialog_login);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(70, 90, 61, 21));
QFont font;
font.setFamily(QString::fromUtf8("\345\256\213\344\275\223"));
font.setPointSize(12);
font.setBold(true);
font.setWeight(75);
label->setFont(font);
label_2 = new QLabel(dialog_login);
label_2->setObjectName(QString::fromUtf8("label_2"));
label_2->setGeometry(QRect(70, 120, 61, 21));
label_2->setFont(font);
pushButton_login = new QPushButton(dialog_login);
pushButton_login->setObjectName(QString::fromUtf8("pushButton_login"));
pushButton_login->setGeometry(QRect(100, 180, 75, 23));
pushButton_cancel = new QPushButton(dialog_login);
pushButton_cancel->setObjectName(QString::fromUtf8("pushButton_cancel"));
pushButton_cancel->setGeometry(QRect(210, 180, 75, 23));
checkBox_remberpass = new QCheckBox(dialog_login);
checkBox_remberpass->setObjectName(QString::fromUtf8("checkBox_remberpass"));
checkBox_remberpass->setGeometry(QRect(100, 150, 71, 16));
checkBox_loginauto = new QCheckBox(dialog_login);
checkBox_loginauto->setObjectName(QString::fromUtf8("checkBox_loginauto"));
checkBox_loginauto->setGeometry(QRect(190, 150, 71, 16));

retranslateUi(dialog_login);
QObject::connect(pushButton_cancel, SIGNAL(clicked()), dialog_login, SLOT(reject()));
QMetaObject::connectSlotsByName(dialog_login);
} // setupUi

void retranslateUi(QDialog *dialog_login)
{
dialog_login->setWindowTitle(QApplication::translate("dialog_login", "\347\231\273\351\231\206", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("dialog_login", "\347\224\250\346\210\267\345\220\215", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("dialog_login", "\345\257\206 \347\240\201", 0, QApplication::UnicodeUTF8));
pushButton_login->setText(QApplication::translate("dialog_login", "\347\231\273\351\231\206", 0, QApplication::UnicodeUTF8));
pushButton_cancel->setText(QApplication::translate("dialog_login", "\345\217\226\346\266\210", 0, QApplication::UnicodeUTF8));
checkBox_remberpass->setText(QApplication::translate("dialog_login", "\350\256\260\344\275\217\345\257\206\347\240\201", 0, QApplication::UnicodeUTF8));
checkBox_loginauto->setText(QApplication::translate("dialog_login", "\350\207\252\345\212\250\347\231\273\351\231\206", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};

namespace Ui2 {
class dialog_login: public Ui_dialog_login {};
} // namespace Ui

QT_END_NAMESPACE

#endif // DIALOG_LOGINGK4464_H


temp.cpp file content:


#include "temp.h"
MainWindow:: MainWindow(QMainWindow *parent)
: QMainWindow(parent)

{
ui->setupUi(this);
}

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


temp.h file content:


#ifndef TEMP_H
#define TEMP_H

#include <QtGui/QMainWindow>
#include "ui_temp.h"
class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QMainWindow *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;

};
#endif // WIDGET_H


ui_temp.h file content,

#ifndef DESIGNERKQ5184_H
#define DESIGNERKQ5184_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
#include <QtGui/QStatusBar>
#include <QtGui/QWidget>

QT_BEGIN_NAMESPACE

class Ui_MainWindow
{
public:
QAction *actionMenu_login;
QWidget *centralwidget;
QMenuBar *menubar;
QMenu *menuOpen;
QStatusBar *statusbar;

void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(800, 600);

actionMenu_login = new QAction(MainWindow);
actionMenu_login->setObjectName(QString::fromUtf8("actionMenu_login"));
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
menubar->setGeometry(QRect(0, 0, 800, 19));
menuOpen = new QMenu(menubar);
menuOpen->setObjectName(QString::fromUtf8("menuOpen"));
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
MainWindow->setStatusBar(statusbar);

menubar->addAction(menuOpen->menuAction());
menuOpen->addAction(actionMenu_login);

retranslateUi(MainWindow);

QMetaObject::connectSlotsByName(MainWindow);
} // setupUi

void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
actionMenu_login->setText(QApplication::translate("MainWindow", "menu_login", 0, QApplication::UnicodeUTF8));
menuOpen->setTitle(QApplication::translate("MainWindow", "open", 0, QApplication::UnicodeUTF8));
} // retranslateUi

};

namespace Ui {
class MainWindow: public Ui_MainWindow {};
} // namespace Ui

QT_END_NAMESPACE

#endif // DESIGNERKQ5184_H

Zlatomir
9th January 2011, 12:59
Here you use an uninitialized pointer:

MainWindow:: MainWindow(QMainWindow *parent)
: QMainWindow(parent)

{
//should have a line like this:
ui = new Ui::MainWindow;
ui->setupUi(this);
}


LE:
same in dialog_login constructor:


ui = new Ui2::dialog_login;
//only then you can use
ui->setupUi(this);

wter27
9th January 2011, 13:19
i changed the code like you said.But it comes out the same error code.
do i need to initializ the pointer of actionMenu_login ?Because it stopped line 32 of the file ui_temp.h .

Zlatomir
9th January 2011, 13:43
That should be Ok, since that code is generated by UIC (unless you modified manually the ui_CLASS.h, you shouldn't do that)

One other problem that i see (might not be related to this, i don't know what could be the result of it, but it is a problem) is that you call show() then you call exec() (i'm pretty sure that is not recommended)
This happens in main.cpp:


// login_box.show(); //comment or delete this line, because exec() will also show your (modal) dialog... so you don't need this
if(login_box.exec()==QDialog::Rejected)//
{

wter27
9th January 2011, 13:51
thank you very much for the tips you give.Because my english is poor.So it's hard for me to understand the word you said .
I would modified the code later to see the problem .