PDA

View Full Version : QMessageBox ( Core Dumped )



cristiano
27th January 2007, 19:41
Staff, the QMessageBox below functions normal. More when I pressed the Esc keyboard key, occurs Core dumped in the App.

% Segmentation fault (core dumped)


QMessageBox mb("App", "Hello Message ",
QMessageBox::NoIcon,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::Cancel, QMessageBox::Escape );

mb.setButtonText( QMessageBox::Yes, "Ok" );
mb.setButtonText( QMessageBox::Cancel, "Cancel" );

QPixmap exportSuccess( QPixmap::fromMimeSource( "message.png" ) );
mb.setIconPixmap(exportSuccess);

mb.exec();

Cris

jacek
27th January 2007, 20:04
Can we see the backtrace?

cristiano
28th January 2007, 01:49
Here it is the method.


void AppForm::primeUpdateQuery()
{
QMessageBox mb("App",
"!!! Here message !!!",
QMessageBox::NoIcon,
QMessageBox::Yes | QMessageBox::Default,
QMessageBox::Cancel, QMessageBox::Escape );

mb.setButtonText( QMessageBox::Yes, "Ok" );
mb.setButtonText( QMessageBox::Cancel, "Cancel" );

QPixmap exportSuccess( QPixmap::fromMimeSource( "message.png" ) );
mb.setIconPixmap(exportSuccess);

/* It get the value of the QDataTable Current */
QSqlRecord *getCurrentItemIdSql = new QSqlRecord();
getCurrentItemIdSql = dataTable->currentRecord();

register int i = dataTable->currentRow();
if ( i == -1 ) i = 0; /* Always use the first row */

else if ( getCurrentItemIdSql )
{
QSqlQuery queryUpdateSaida;

switch( mb.exec() )
{
case QMessageBox::Yes:

/* Now, it executes query for the exit of the occurrence */
queryUpdateSaida.prepare( QUERY_EXIT_OCCURRENCE "id_ocorrencia= :id_ocorrencia AND id_viatura= :id_viatura "
"AND id_cidade= :id_cidade ;" );

queryUpdateSaida.bindValue( ":id_ocorrencia", getCurrentItemIdSql->value("id_ocorrencia").toInt() );
queryUpdateSaida.bindValue( ":id_viatura", getCurrentItemIdSql->value("id_viatura").toString() );
queryUpdateSaida.bindValue( ":id_cidade", getCurrentItemIdSql->value("id_cidade").toInt() );

if ( queryUpdateSaida.exec() )
{
cout << "App ==> OK" << endl;

} else {

cout << "App ==> Error" << endl;
}

dataTable->refresh(QDataTable::RefreshData);
break;

case QMessageBox::Cancel:

dataTable->refresh(QDataTable::RefreshData);
break;

default:

cout << "App ==> Case default" << endl;

}

return;
}
}

wysota
28th January 2007, 10:28
Jacek wanted a backtrace (a list of functions called when the process crashed generated by a debugger), not the code.

cristiano
28th January 2007, 16:07
Ok, I am using option -g in qmake.

% gdb ./app
(gdb) run
....
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x813e000 (LWP 100142)]
0x2845623c in QButton::animateClick () from /usr/X11R6/lib/libqt-mt.so.3
(gdb)

This is the error when it is Esc keyboard.

wysota
28th January 2007, 17:37
when in gdb use the "bt" command to print a backtrace.

cristiano
28th January 2007, 18:04
Ok,

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x813e000 (LWP 100077)]
0x2845623c in QButton::animateClick () from /usr/X11R6/lib/libqt-mt.so.3
(gdb) bt
#0 0x2845623c in QButton::animateClick () from /usr/X11R6/lib/libqt-mt.so.3
#1 0x28561971 in QMessageBox::keyPressEvent () from /usr/X11R6/lib/libqt-mt.so.3
#2 0x283fd31c in QWidget::event () from /usr/X11R6/lib/libqt-mt.so.3
#3 0x2836e545 in QApplication::internalNotify () from /usr/X11R6/lib/libqt-mt.so.3
#4 0x2836ed08 in QApplication::notify () from /usr/X11R6/lib/libqt-mt.so.3
#5 0x28307b78 in QETWidget::translateKeyEvent () from /usr/X11R6/lib/libqt-mt.so.3
#6 0x2830e37e in QApplication::x11ProcessEvent () from /usr/X11R6/lib/libqt-mt.so.3
#7 0x283205ec in QEventLoop::processEvents () from /usr/X11R6/lib/libqt-mt.so.3
#8 0x2838293b in QEventLoop::enterLoop () from /usr/X11R6/lib/libqt-mt.so.3
#9 0x2836d8a8 in QApplication::enter_loop () from /usr/X11R6/lib/libqt-mt.so.3
#10 0x285388c0 in QDialog::exec () from /usr/X11R6/lib/libqt-mt.so.3
#11 0x0805f082 in compForm::primeUpdateSaida (this=0x8265200) at src/comp/compForm.cpp:647
#12 0x080a3ab8 in compForm::qt_invoke (this=0x8265200, _id=74, _o=0xbfbfdf10) at src/comForm/moc_compForm.cpp:161
#13 0x283ca6a4 in QObject::activate_signal () from /usr/X11R6/lib/libqt-mt.so.3
#14 0x283cad15 in QObject::activate_signal () from /usr/X11R6/lib/libqt-mt.so.3
#15 0x286d1a4c in QButton::clicked () from /usr/X11R6/lib/libqt-mt.so.3
#16 0x2845695a in QButton::mouseReleaseEvent () from /usr/X11R6/lib/libqt-mt.so.3
#17 0x283fd2b7 in QWidget::event () from /usr/X11R6/lib/libqt-mt.so.3
#18 0x2836e545 in QApplication::internalNotify () from /usr/X11R6/lib/libqt-mt.so.3
#19 0x2836e801 in QApplication::notify () from /usr/X11R6/lib/libqt-mt.so.3
#20 0x2830ff1f in QETWidget::translateMouseEvent () from /usr/X11R6/lib/libqt-mt.so.3
#21 0x2830ee9f in QApplication::x11ProcessEvent () from /usr/X11R6/lib/libqt-mt.so.3
#22 0x283205ec in QEventLoop::processEvents () from /usr/X11R6/lib/libqt-mt.so.3
#23 0x2838293b in QEventLoop::enterLoop () from /usr/X11R6/lib/libqt-mt.so.3
#24 0x28382894 in QEventLoop::exec () from /usr/X11R6/lib/libqt-mt.so.3
#25 0x2836d880 in QApplication::exec () from /usr/X11R6/lib/libqt-mt.so.3
#26 0x08058165 in main (argc=1, argv=0xbfbfe9fc) at src/main.cpp:286
(gdb)

wysota
28th January 2007, 18:22
In my opinion you should either call

mb.setButtonText( QMessageBox::Escape, "Text for 'escape' button" );
or make Cancel and Escape the same button (by substituting the comma with a pipe "|"). I doubt Escape should be used as a button number, are you sure you want that?

cristiano
28th January 2007, 19:23
If it will be added “|” occurs error in the compilation.

QMessageBox::Cancel | QMessageBox::Escape


src/comp/compForm.cpp::540: error: no matching function for call to `QMessageBox::QMessageBox(const char[21], const QString, QMessageBox::Icon, int, int)'
/usr/X11R6/include/qmessagebox.h:192: note: candidates are: QMessageBox::QMessageBox(const QMessageBox&)
/usr/X11R6/include/qmessagebox.h:68: note: QMessageBox::QMessageBox(const QString&, const QString&, QMessageBox::Icon, int, int, int, QWidget*, const char*, bool, uint)
/usr/X11R6/include/qmessagebox.h:64: note: QMessageBox::QMessageBox(QWidget*, const char*)
*** Error code 1

wysota
28th January 2007, 19:52
Pass QMessageBox::NoButton as the third int argument.

ederbs
28th January 2007, 21:59
It makes thus.

...
QMessageBox::NoIcon, QMessageBox::Yes | QMessageBox::Default,
QMessageBox::Cancel | QMessageBox::Escape, QMessageBox::NoButton );