Segmentation fault... [SOLVED]
-
For future refence: opening/closing the same database multiple times causes a segmentation fault, it can happen either at the seccond try or at the tenth but it`s going to crack your head.
//----------------------------------------SOLVED------------------------------------------------------------------------
Hi guys...well im having this problem that is cracking my head...I have the following code:
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
stack_ventanas = new QStackedWidget;
stack_ventanas->addWidget (this->ui->centralWidget);
this->setCentralWidget (stack_ventanas);
randurl = new RandomInfo ();
frase_autor = QStringList ();
}void MainWindow::accionFinalizada_Cancelada (QString url){
this->ui->menuBar->show ();
frase_autor = randurl->getFraseRandom ();
this->ui->label_author->setText (frase_autor.at (1));
this->ui->label_text->setFont (QFont("Courier", 8));
this->ui->label_text->setText (frase_autor.at (0));
frase_autor.clear();
qDebug () << "fuck my luck";
if (stack_ventanas->currentIndex () != 0){
stack_ventanas->removeWidget (stack_ventanas->widget (1));
qDebug () << "fuck my luck";
stack_ventanas->setCurrentIndex (0);
}
qDebug () << "fuck my luck";
}void MainWindow::on_actionFacturacion_triggered()
{
this->ui->menuBar->hide ();
tipo_factura->exec ();
wfact = new widgetFacturacion(this, this->handler, tipo_factura->getTipoFactura ());
connect (wfact, SIGNAL(widgetClosed (QString )) ,this, SLOT(accionFinalizada_Cancelada(QString)));
stack_ventanas->addWidget (wfact);
stack_ventanas->setCurrentIndex (1);
}@If I execute this code I receive the following output:
bq. fuck my luck
fuck my luck
fuck my luck
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
fuck my luck
fuck my luck
fuck my luck
The program has unexpectedly finished. Exited with code -1073741819I dont know why if I execute "void MainWindow::accionFinalizada_Cancelada (QString url)" one time it doesnt crash but when I execute it again I receive segfault...
-
And where does it crash?
Run the program in a debugger, it will drop you at the line where the crash happens. -
@ /frase_autor = randurl->getFraseRandom ();
this->ui->label_author->setText (frase_autor.at (1));
this->ui->label_text->setFont (QFont("Courier", 8));
this->ui->label_text->setText (frase_autor.at (0));
qDebug () << "fuck my luck";/@It crashes somewhere there...I run it in debugging mode and tells me
bq. inline QString::~QString() { if (!d->ref.deref()) free(d); }
0 oraclient11!kpufhndl0 F:\oraclexe\ora\app\oracle\product\11.2.0\server\bin\oraclient11.dll 0 0x213e51e
1 ?? 0 0x38
2 oraclient11!kpufhndl F:\oraclexe\ora\app\oracle\product\11.2.0\server\bin\oraclient11.dll 0 0x213e4e4
3 ?? 0 0x4842434
4 ?? qstring.h 883 0x2
5 ?? 0 0x23c0d0That means somewhere there im deleting a QString right? but im not doing that...
-
So, obviously, the crash is not in the methods you posted above. Did you compile our app in debug mode? If not, do so please. That adds some information on which line the desaster starts in your application.
Did you connect that signal that deletes from the widget stack to some other slot?
-
Yes I compile it in debug mode. It tell`s me what i copied:
in QString.h line 833: method: inline QString::~QString() { if (!d->ref.deref()) free(d); }
That signal is connected to every action of my menuBar, for example:
@//---------------------------------Abrir Widget con model de la tabla de productos
void MainWindow::on_actionBuscar_producto_triggered()
{
this->ui->menuBar->hide ();
tabla_consultas = new Tablas_Consulta (this, 0);
connect (tabla_consultas, SIGNAL (finaliza_consulta(QString)), this, SLOT (accionFinalizada_Cancelada(QString)));
stack_ventanas->addWidget (tabla_consultas);
stack_ventanas->setCurrentIndex (1);
}//---------------------------------Abrir Widget con model de la tabla de clientes
void MainWindow::on_actionBuscar_cliente_triggered()
{
this->ui->menuBar->hide ();
tabla_consultas = new Tablas_Consulta (this, 1);
connect (tabla_consultas, SIGNAL (finaliza_consulta(QString)), this, SLOT (accionFinalizada_Cancelada(QString)));
stack_ventanas->addWidget (tabla_consultas);
stack_ventanas->setCurrentIndex (1);
}//--------------------------------Dar de alta un producto
void MainWindow::on_actionAlta_de_producto_triggered()
{
this->menuBar ()->hide ();
formulario = new Formulario (0, 0);
connect (formulario, SIGNAL (elemento_ingresado (QString)), this, SLOT (accionFinalizada_Cancelada(QString)));
stack_ventanas->addWidget (formulario);
stack_ventanas->setCurrentIndex (1);
}@Every action opens a widget that when it is no longer shown it is deleted from the stack...
-
I managed to change some things and the error is defenitely because of the database connections:
@0 oraclient11!kpufhndl0 F:\oraclexe\ora\app\oracle\product\11.2.0\server\bin\oraclient11.dll 0 0x299e51e
1 ?? 0 0x50e0cc0
2 oraclient11!kpufhndl F:\oraclexe\ora\app\oracle\product\11.2.0\server\bin\oraclient11.dll 0 0x299e4e4
3 ?? 0 0x5108e40
4 ?? qstring.h 883 0x2
5 ?? 0 0x23bed0
@thats the output of the debugging segmentation fault...And this is the application output:
bq. Debugging starts
NOD32 protected [MSAFD Tcpip [TCP/IP]]
NOD32 protected [MSAFD Tcpip [UDP/IP]]
NOD32 protected [MSAFD Tcpip [RAW/IP]]
NOD32 protected [RSVP UDP Service Provider]
NOD32 protected [RSVP TCP Service Provider]
~QOCIResult: unable to free statement handle
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
(Internal error: pc 0x1 in read in psymtab, but not in symtab.)
(Internal error: pc 0x0 in read in psymtab, but not in symtab.)
(Internal error: pc 0x1 in read in psymtab, but not in symtab.)Any ideas? because i looked this errors on the internet related to the database and nothing :(
-
The solution is at the top of the very first post - in case someone looks at the end of the thread for the solution :)
-
[quote author="Volker" date="1329072554"]The solution is at the top of the very first post - in case someone looks at the end of the thread for the solution :)[/quote]
lol sorry for that ...next time I ll post at bottom