delete model to prevent memory leak
This commit is contained in:
parent
2003530587
commit
fb8bcc71e2
2 changed files with 17 additions and 1 deletions
|
@ -9,8 +9,9 @@ SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
|
|||
{
|
||||
ui_.setupUi(this);
|
||||
ui_.editButton->setVisible(false);
|
||||
market_ = dynamic_cast<MainWindow*>(parent)->getMarketplace();
|
||||
SellerModel* model =
|
||||
new SellerModel(dynamic_cast<MainWindow*>(parent)->getMarketplace(), ui_.tableView);
|
||||
new SellerModel(market_, ui_.tableView);
|
||||
ui_.tableView->setModel(model);
|
||||
ui_.tableView->setColumnHidden(0, true); // hide the uuid
|
||||
connect(ui_.newButton, &QPushButton::clicked, this, &SellerDialog::on_newButton_clicked);
|
||||
|
@ -21,6 +22,11 @@ SellerDialog::SellerDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent,
|
|||
&SellerDialog::onSellerViewSelectionChanged);
|
||||
}
|
||||
|
||||
SellerDialog::~SellerDialog()
|
||||
{
|
||||
delete ui_.tableView->model();
|
||||
}
|
||||
|
||||
void SellerDialog::on_newButton_clicked()
|
||||
{
|
||||
ui_.tableView->reset();
|
||||
|
@ -38,6 +44,14 @@ void SellerDialog::on_deleteButton_clicked()
|
|||
if (selModel->hasSelection() == false)
|
||||
return;
|
||||
|
||||
if (market_->getSales().size() > 0) {
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Hinweis",
|
||||
"Da die Verkaufsphase schon begonnen hat (Artikel wurden bereits verkauft) können Sie keine Verkäufer mehr löschen.",
|
||||
QMessageBox::StandardButton::Ok, this)
|
||||
.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
auto dlgResult =
|
||||
QMessageBox(QMessageBox::Icon::Warning, "Sind Sie sicher?",
|
||||
"Löschen wirkt sich direkt auf die Datenbank aus. Möchten Sie fortfahren?",
|
||||
|
|
|
@ -14,6 +14,7 @@ class SellerDialog : public QDialog
|
|||
public:
|
||||
SellerDialog(QWidget* parent = nullptr,
|
||||
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
||||
~SellerDialog();
|
||||
|
||||
private slots:
|
||||
void onSellerViewSelectionChanged(const QItemSelection& selected,
|
||||
|
@ -25,6 +26,7 @@ class SellerDialog : public QDialog
|
|||
void on_model_duplicateSellerNo(const QString& message);
|
||||
virtual void accept() override;
|
||||
Ui::SellerDialog ui_;
|
||||
Marketplace* market_;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue