I have a simple gui that has a text field, a drop-down menu, and a go button. I can specify the name and class of a part I'm looking for, and call a function by connecting the "go" button to a slot that runs a function that I already made.
However, when the slot function is done with everything, it calls a function in xstring
, that's deleting some massive xstring
. It goes to this function:
void _Tidy(bool _Built = false,
size_type _Newsize = 0)
{ // initialize buffer, deallocating any storage
if (!_Built)
;
else if (this->_BUF_SIZE <= this->_Myres)
{ // copy any leftovers to small buffer and deallocate
pointer _Ptr = this->_Bx._Ptr;
this->_Getal().destroy(&this->_Bx._Ptr);
if (0 < _Newsize)
_Traits::copy(this->_Bx._Buf,
_STD addressof(*_Ptr), _Newsize);
this->_Getal().deallocate(_Ptr, this->_Myres + 1);
}
this->_Myres = this->_BUF_SIZE - 1;
_Eos(_Newsize);
}
And my program executes a break at this->_Getal().deallocate(_Ptr, this->_Myres + 1);
.
Here's the code for the gui:
#include <QtGui>
#include <QApplication>
#include <QComboBox>
#include "gui.h"
#include <vector>
std::vector<std::string> PartClasses;
gui::gui(QWidget *parent) : QDialog(parent){
getPartClasses(PartClasses); //my own function, does not affect how the gui runs, just puts strings in PartClasses
label1 = new QLabel(tr("Insert Name (Optional):"));
label2 = new QLabel(tr("Class Name (Required):"));
lineEdit = new QLineEdit;
goButton = new QPushButton(tr("&Go"));
goButton->setDefault(true);
connect(goButton, SIGNAL(clicked()), this, SLOT(on_go_clicked()));
cb = new QComboBox();
for(int i = 0; i < PartClasses.size(); i++)
cb->addItem(QString::fromStdString(PartClasses[i]));
//*add widgets to layouts, removed for space*
setWindowTitle(tr("TEST"));
setFixedHeight(sizeHint().height());
}
void gui::on_go_clicked(){
std::string str(cb->currentText().toStdString());
updateDB(str, lineEdit->text().toUtf8().constData()); //my function, does not affect the gui.
QApplication::exit();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
gui *stuff = new gui;
stuff->show();
return app.exec();
}
What is it doing? When I'm done with the slot, shouldn't the gui just come back up, so that I can specify a new object? How can I get it to either not delete this object, or get it to succeed?