<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[kaputter Heap: double free or corruption (out) beim löschen des Objektes]]></title><description><![CDATA[<p>Hallo an alle,<br />
ich bekomme immer einen Pointerfehler, wenn ich ein Objekt löschen möchte, nur finde ich den nicht.<br />
Kann mir bitte jemand mit ein paar zusätzlichen Augen, und mehr Erfahrung/Wissen helfen?</p>
<p>Ich erstelle in einer Funktion ein Objekt auf dem Heap.</p>
<pre><code>ViewQuerryOption *newView= new ViewQuerryOption();
newView-&gt;tableViewOption(&amp;querry, &amp;viewName, &amp;TqmStorage);
</code></pre>
<p>Das möchte ich am Ende der Funktion nun wie folgt löschen.</p>
<pre><code>delete newView;
</code></pre>
<p>Nur leider bekomme ich an der Stelle, genauer beim Destruktor des Objekts, einen Pointer Fehler [...] &quot;double free or corruption (out)&quot; [...]<br />
Durch googeln nach diesem Fehler finde ich zahlreiche Beispiele wie ich mir noch so den Speicher zerschießen kann, nur nichts was ich adaptieren kann, zumindest seh ich es nicht.</p>
<p>Hier der Code zu &quot;ViewQuerryOption.h&quot;</p>
<pre><code>#ifndef VIEWQUERRYOPTION_H
#define VIEWQUERRYOPTION_H

#include &quot;MainTable.h&quot;
#include &quot;ModulQuery.h&quot;

#include &lt;QWidget&gt;
#include &lt;QtGui&gt;
#include &lt;QMap&gt;

using namespace std;

class ViewQuerryOption : public QDialog
{
    Q_OBJECT
public:
    explicit ViewQuerryOption(QWidget *parent = 0);
    ~ViewQuerryOption();
    void tableViewOption(QString *querry, QString *viewName, QMap &lt;QString, ModulQuery&gt; *TqmStorage);
private:
    MainTable *ptrAufTable;

    QCheckBox plz;
    QCheckBox number;
    QCheckBox city;
    QCheckBox street;

    QCheckBox firstName;
    QCheckBox lastName;
    QCheckBox male;

    QCheckBox roll;
    QCheckBox companyName;

    QCheckBox phone;
    QCheckBox mail;

    QRadioButton  rbUser;
    QRadioButton  rbFirma;
    QRadioButton  rbInstanz;

    QComboBox  whereSelect;
    QComboBox  relation;
    QLineEdit  searcher;
    QLineEdit  nameOfV;

    QVBoxLayout  vBoxLall;
    QVBoxLayout  vRadioL;
    QVBoxLayout  vBoxLaddress;
    QVBoxLayout  vBoxLinstanz;
    QVBoxLayout  vBoxLnext;
    QVBoxLayout  vBoxLcontact;
    QVBoxLayout  vL;
    QVBoxLayout  vButtonNemaL;

    QHBoxLayout  hWhereL;
    QHBoxLayout  hInAnL;
    QHBoxLayout  hNeCoL;
    QHBoxLayout  hL;
    QHBoxLayout  hViewLabelL;
    QHBoxLayout  hFunctionButtonL;

    QPushButton  ok;
    QPushButton  cancel;

    QGroupBox  preSelect;
    QGroupBox  selectViews;
    QGroupBox  selectWhere;
    QGroupBox  nameLabel;

    QLabel  addressData;
    QLabel  instanzData;
    QLabel  nextData;
    QLabel  contectData;
    QLabel  nameOfView;

    QSignalMapper  signalMapper;
    QString  *makingQuery;
    QString  *localViewName;
    QMap &lt;QString, ModulQuery&gt; *localTmpMap;

    QMessageBox msgBox;
signals:

public slots:
    void okPushed();
    void createQuery();
    void addToComboBox(const int &amp;CheckBoxName);

};

#endif // VIEWQUERRYOPTION_H
</code></pre>
<p>Hier der Code des Objektes &quot;ViewQuerryOption.cpp&quot;</p>
<pre><code>#include &quot;ViewQuerryOption.h&quot;

ViewQuerryOption::ViewQuerryOption(QWidget *parent) : QDialog(parent)
{
    //Erzeugung aller grafischen bestandteile des fensteres und verschachtelung in Layouts

    //Hinzufügen der Objete, deren Signale gebündelt werden
    signalMapper.setMapping(&amp;plz,1);
    signalMapper.setMapping(&amp;number,2);
    signalMapper.setMapping(&amp;city,3);
    signalMapper.setMapping(&amp;street,4);
    signalMapper.setMapping(&amp;firstName,5);
    signalMapper.setMapping(&amp;lastName,6);
    signalMapper.setMapping(&amp;male,7);
    signalMapper.setMapping(&amp;roll,8);
    signalMapper.setMapping(&amp;companyName,9);
    signalMapper.setMapping(&amp;phone,10);
    signalMapper.setMapping(&amp;mail,11);

    // Beschriftung der RadioButton
    rbInstanz.setText(&quot;Instanz / Person&quot;);
    rbFirma.setText(&quot;Firma&quot;);
    rbUser.setText(&quot;D-Manager Nutzer&quot;);

    // vertikales Layout für die Radiobutton in der oberen GroupBox
    vRadioL.addWidget(&amp;rbInstanz);
    vRadioL.addWidget(&amp;rbFirma);
    vRadioL.addWidget(&amp;rbUser);
    //Fügt der GroupBox das Layout mit den 3 RadioButton hinzu
    preSelect.setLayout(&amp;vRadioL);

    // Beschriftung der Labels
    addressData.setText(&quot;Adressdaten&quot;);
    instanzData.setText(&quot;Instanz / Personendaten&quot;);
    nextData.setText(&quot;weitere Informationen&quot;);
    contectData.setText(&quot;Kontaktdaten&quot;);
    nameOfView.setText(&quot;Name der View:&quot;);

    // Beschriftung der CheckBoxen
    street.setText(&quot;Strasse&quot;);
    number.setText(&quot;Hausnummer&quot;);
    plz.setText(&quot;Postleitzahl&quot;);
    city.setText(&quot;Stadt&quot;);
    male.setText(&quot;Anrede&quot;);
    lastName.setText(&quot;Nachname&quot;);
    firstName.setText(&quot;Vorname&quot;);
    companyName.setText(&quot;Firmenname&quot;);
    roll.setText(&quot;Instanzname&quot;);
    phone.setText(&quot;Telefon&quot;);
    mail.setText(&quot;E-Mail&quot;);

    // vertikales Layout für die Checkboxen zur Adresse
    vBoxLaddress.addWidget(&amp;addressData);
    vBoxLaddress.addWidget(&amp;street);
    vBoxLaddress.addWidget(&amp;number);
    vBoxLaddress.addWidget(&amp;plz);
    vBoxLaddress.addWidget(&amp;city);

    // vertikales Layout für die Checkboxen zur Instanz
    vBoxLinstanz.addWidget(&amp;instanzData);
    vBoxLinstanz.addWidget(&amp;male);
    vBoxLinstanz.addWidget(&amp;lastName);
    vBoxLinstanz.addWidget(&amp;firstName);

    // Horizontales Layout für die vertikalen Layouts der Checkboxen zur Adresse und Instanz
    hInAnL.addLayout(&amp;vBoxLinstanz);
    hInAnL.addLayout(&amp;vBoxLaddress);

    // vertikales Layout für die Checkboxen zur weiteren Daten
    vBoxLnext.addWidget(&amp;nextData);
    vBoxLnext.addWidget(&amp;companyName);
    vBoxLnext.addWidget(&amp;roll);

    // vertikales Layout für die Checkboxen zur Kontaktdaten
    vBoxLcontact.addWidget(&amp;contectData);
    vBoxLcontact.addWidget(&amp;phone);
    vBoxLcontact.addWidget(&amp;mail);

    // vertikales Layout für die Radiobutton in der mittleren GroupBox
    hNeCoL.addLayout(&amp;vBoxLnext);
    hNeCoL.addLayout(&amp;vBoxLcontact);

    // Fügt die 2 horizontalen layouts nochmal i ein vertikales zusammen
    vBoxLall.addLayout(&amp;hNeCoL);
    vBoxLall.addLayout(&amp;hInAnL);

    //Fügt der mittleren GroupBox das Layout mit den CheckBoxen hinzu
    selectViews.setLayout(&amp;vBoxLall);

    //Fügt den Comboboxen die Standard Auswahlmöglichkeiten hinzu
    whereSelect.addItem(&quot;Suche verfeinern&quot;);
    relation.addItem(&quot;=&quot;);
    relation.addItem(&quot;&lt;&quot;);
    relation.addItem(&quot;&gt;&quot;);

    // vertikales Layout für die untere Filtefunktion
    hWhereL.addWidget(&amp;whereSelect);
    hWhereL.addWidget(&amp;relation);
    hWhereL.addWidget(&amp;searcher);

    // fügt layout GroupBox hinzu
    selectWhere.setLayout(&amp;hWhereL);

    // Button vorbereiten
    ok.setText(&quot;OK&quot;);
    cancel.setText(&quot;Abbrechen&quot;);
    //Namenslabel und Funktionsbutten zu einem Layout formen
    hViewLabelL.addWidget(&amp;nameOfView);
    hViewLabelL.addWidget(&amp;nameOfV);
    hFunctionButtonL.addWidget(&amp;ok);
    hFunctionButtonL.addWidget(&amp;cancel);
    vButtonNemaL.addLayout(&amp;hViewLabelL);
    vButtonNemaL.addLayout(&amp;hFunctionButtonL);

    nameLabel.setLayout(&amp;vButtonNemaL);

    // Fügt die 3 Groupboxen eine horizontalen Layout hinzu
    hL.addWidget(&amp;preSelect);
    hL.addWidget(&amp;selectViews);
    vL.addLayout(&amp;hL);
    vL.addWidget(&amp;selectWhere);
    vL.addWidget(&amp;nameLabel);

    // Setzt das gesammte Layout
    setLayout(&amp;vL);

    QObject::connect(&amp;ok,SIGNAL(clicked()),this,SLOT(okPushed()));
    QObject::connect(&amp;cancel,SIGNAL(clicked()),this,SLOT(close()));

    //Immer wenn eine Checkbox angeklickt wurde und sich damit ihr Status geänder hatte wird diese CheckBox
    //in den Mappere geschrieben
    QObject::connect( &amp;plz, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;number, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;city, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;street, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;firstName, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;lastName, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;male, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;roll, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;companyName, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;phone, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;mail, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );

    QObject::connect(&amp;signalMapper, SIGNAL(mapped(const int&amp;)), this, SLOT(addToComboBox(const int &amp;)) );
}

ViewQuerryOption::~ViewQuerryOption()
{

}

//fügt die angehakten spalten zur ComboBox hinzu um diese weiter zu nutzen.
void ViewQuerryOption::addToComboBox(const int &amp;CheckBoxName)
{

    switch (CheckBoxName)
    {
    case 1 :
        if (plz.isChecked())
        {
            whereSelect.addItem(&quot;PLZ&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;PLZ&quot;));
        }
    break;
    case 2 :
        if (number.isChecked())
        {
            whereSelect.addItem(&quot;Hausnummer&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Hausnummer&quot;));
        }
    break;
    case 3 :
        if (city.isChecked())
        {
            whereSelect.addItem(&quot;Stadt&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Stadt&quot;));
        }
    break;
    case 4 :
        if (street.isChecked())
        {
            whereSelect.addItem(&quot;Strasse&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Strasse&quot;));
        }
    break;
    case 5 :
        if (firstName.isChecked())
        {
            whereSelect.addItem(&quot;Vorname&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Vorname&quot;));
        }
    break;
    case 6 :
        if (lastName.isChecked())
        {
            whereSelect.addItem(&quot;Nachname&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Nachname&quot;));
        }
    break;
    case 7 :
        if (male.isChecked())
        {
            whereSelect.addItem(&quot;Anrede&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Anrede&quot;));
        }
    break;
    case 8 :
        if (roll.isChecked())
        {
            whereSelect.addItem(&quot;Rolle&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Rolle&quot;));
        }
    break;
    case 9 :
        if (companyName.isChecked())
        {
            whereSelect.addItem(&quot;Firma&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Firma&quot;));
        }
    break;
    case 10 :
        if (phone.isChecked())
        {
            whereSelect.addItem(&quot;Telefon&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Telefon&quot;));
        }
    break;
    case 11 :
        if (mail.isChecked())
        {
            whereSelect.addItem(&quot;E-Mail&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;E-Mail&quot;));
        }
    break;

    }
}

void ViewQuerryOption::okPushed()
{
    if (nameOfV.text()==&quot;&quot;)
    {
        const wchar_t* QboxText = L&quot;Bitte geben Sie einen Namen für die neue Ansicht ein!\n&quot;;
        msgBox.setWindowTitle(&quot;Name fehlt&quot;);
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.setText(QString(QString::fromWCharArray(QboxText)));
        msgBox.exec();
    }else if(localTmpMap-&gt;contains(nameOfV.text()))
    {
        /*ModulQuery foo;
        foo = localTmpMap-&gt;value(nameOfV.text());
        cout &lt;&lt;&quot;Querry: &quot; &lt;&lt;foo.getQuery().toStdString() &lt;&lt;endl;
        */
        const wchar_t* QboxText = L&quot;Dieser Name existiert bereits! Bitte wählen Sie einen anderen.\n&quot;;
        msgBox.setWindowTitle(&quot;Name existiert&quot;);
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.setText(QString(QString::fromWCharArray(QboxText)));
        msgBox.exec();
    }else
    {
        this-&gt;createQuery();
        this-&gt;close();
    }

}
/*
 * Übernimmt die Zeiger auf den Querry und den Tabnamen auf Klasseenvariablen
 * und startet die View.
*/
void ViewQuerryOption::tableViewOption(QString *query, QString *viewName, QMap &lt;QString, ModulQuery&gt; *TqmStorage)
{
    makingQuery=query;
    localViewName=viewName;
    localTmpMap = TqmStorage;
    this-&gt;exec();
}

/*
 * Erstellt aus den ANgaben des Nutuzers einen gültigen SQL Query
*/
void ViewQuerryOption::createQuery()
{

    *makingQuery=&quot;SELECT&quot;;

    if (plz.isChecked())
    {*makingQuery=*makingQuery+&quot; plz,&quot;;}

    if (number.isChecked())
    {*makingQuery=*makingQuery+&quot; hausnummer,&quot;;}

    if (city.isChecked())
    {*makingQuery=*makingQuery+&quot; ort,&quot;;}

    if (street.isChecked())
    {*makingQuery=*makingQuery+&quot; strasse,&quot;;}

    if (firstName.isChecked())
    {*makingQuery=*makingQuery+&quot; vorname,&quot;;}

    if (lastName.isChecked())
    {*makingQuery=*makingQuery+&quot; nachname,&quot;;}

    if (male.isChecked())
    {*makingQuery=*makingQuery+&quot; anrede,&quot;;}

    if (roll.isChecked())
    {*makingQuery=*makingQuery+&quot; rollenname,&quot;;}

    if (companyName.isChecked())
    {*makingQuery=*makingQuery+&quot; firmenname,&quot;;}

    if (phone.isChecked())
    {*makingQuery=*makingQuery+&quot; telefonnummer, beschreibung,&quot;;}

    if (mail.isChecked())
    {*makingQuery=*makingQuery+&quot; mail,&quot;;}

    //löscht das letzte Komma bevor FROM geschrieben wird. SQL Fehler vermeiden!
     makingQuery-&gt;remove((makingQuery-&gt;length()-1),1);
    *makingQuery=*makingQuery+&quot; FROM&quot;;

    if (plz.isChecked() || number.isChecked() || city.isChecked() || street.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_anschrift,&quot;;}

    if (firstName.isChecked() || lastName.isChecked() || male.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_person,&quot;;}

    if (phone.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_phone,&quot;;}

    if (mail.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_mail,&quot;;}

    //löscht das letzte Komma vor WHERE geschrieben wird. SQL Fehler vermeiden!
    makingQuery-&gt;remove((makingQuery-&gt;length()-1),1);

    if (whereSelect.currentText()==&quot;Suche verfeinern&quot;)
    {
    }else
    {
        *makingQuery=*makingQuery+&quot; WHERE &quot;;
        *makingQuery=*makingQuery+whereSelect.currentText();
        *makingQuery=*makingQuery+relation.currentText();
        *makingQuery=*makingQuery+&quot;'&quot;;
        *makingQuery=*makingQuery+searcher.text();
        *makingQuery=*makingQuery+&quot;'&quot;;

    }
    *localViewName=nameOfV.text();
}
</code></pre>
<p>BTW.: Ich arbeite hier mit der QT Bibliothek da es sich aber um Speicherfehler handelt dachte ich ein C++ Forum ist geeigneter. Ich weis es ist viel Code, das Meiste sind Form Objekte die in Layouts geschachtelt werden.</p>
<p>Ist die Funktion ein gängiger Workaround oder liegt da schon der Fehler begraben?</p>
<pre><code>void ViewQuerryOption::tableViewOption(QString *query, QString *viewName, QMap &lt;QString, ModulQuery&gt; *TqmStorage)
{
    makingQuery=query;
    localViewName=viewName;
    localTmpMap = TqmStorage;
    this-&gt;exec();
}
</code></pre>
<p>Vielen Dank schonmal für eure Hilfe!</p>
<p>Gruß Meho</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/326539/kaputter-heap-double-free-or-corruption-out-beim-löschen-des-objektes</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 23:51:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/326539.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 23 Jun 2014 13:02:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to kaputter Heap: double free or corruption (out) beim löschen des Objektes on Mon, 23 Jun 2014 13:07:32 GMT]]></title><description><![CDATA[<p>Hallo an alle,<br />
ich bekomme immer einen Pointerfehler, wenn ich ein Objekt löschen möchte, nur finde ich den nicht.<br />
Kann mir bitte jemand mit ein paar zusätzlichen Augen, und mehr Erfahrung/Wissen helfen?</p>
<p>Ich erstelle in einer Funktion ein Objekt auf dem Heap.</p>
<pre><code>ViewQuerryOption *newView= new ViewQuerryOption();
newView-&gt;tableViewOption(&amp;querry, &amp;viewName, &amp;TqmStorage);
</code></pre>
<p>Das möchte ich am Ende der Funktion nun wie folgt löschen.</p>
<pre><code>delete newView;
</code></pre>
<p>Nur leider bekomme ich an der Stelle, genauer beim Destruktor des Objekts, einen Pointer Fehler [...] &quot;double free or corruption (out)&quot; [...]<br />
Durch googeln nach diesem Fehler finde ich zahlreiche Beispiele wie ich mir noch so den Speicher zerschießen kann, nur nichts was ich adaptieren kann, zumindest seh ich es nicht.</p>
<p>Hier der Code zu &quot;ViewQuerryOption.h&quot;</p>
<pre><code>#ifndef VIEWQUERRYOPTION_H
#define VIEWQUERRYOPTION_H

#include &quot;MainTable.h&quot;
#include &quot;ModulQuery.h&quot;

#include &lt;QWidget&gt;
#include &lt;QtGui&gt;
#include &lt;QMap&gt;

using namespace std;

class ViewQuerryOption : public QDialog
{
    Q_OBJECT
public:
    explicit ViewQuerryOption(QWidget *parent = 0);
    ~ViewQuerryOption();
    void tableViewOption(QString *querry, QString *viewName, QMap &lt;QString, ModulQuery&gt; *TqmStorage);
private:
    MainTable *ptrAufTable;

    QCheckBox plz;
    QCheckBox number;
    QCheckBox city;
    QCheckBox street;

    QCheckBox firstName;
    QCheckBox lastName;
    QCheckBox male;

    QCheckBox roll;
    QCheckBox companyName;

    QCheckBox phone;
    QCheckBox mail;

    QRadioButton  rbUser;
    QRadioButton  rbFirma;
    QRadioButton  rbInstanz;

    QComboBox  whereSelect;
    QComboBox  relation;
    QLineEdit  searcher;
    QLineEdit  nameOfV;

    QVBoxLayout  vBoxLall;
    QVBoxLayout  vRadioL;
    QVBoxLayout  vBoxLaddress;
    QVBoxLayout  vBoxLinstanz;
    QVBoxLayout  vBoxLnext;
    QVBoxLayout  vBoxLcontact;
    QVBoxLayout  vL;
    QVBoxLayout  vButtonNemaL;

    QHBoxLayout  hWhereL;
    QHBoxLayout  hInAnL;
    QHBoxLayout  hNeCoL;
    QHBoxLayout  hL;
    QHBoxLayout  hViewLabelL;
    QHBoxLayout  hFunctionButtonL;

    QPushButton  ok;
    QPushButton  cancel;

    QGroupBox  preSelect;
    QGroupBox  selectViews;
    QGroupBox  selectWhere;
    QGroupBox  nameLabel;

    QLabel  addressData;
    QLabel  instanzData;
    QLabel  nextData;
    QLabel  contectData;
    QLabel  nameOfView;

    QSignalMapper  signalMapper;
    QString  *makingQuery;
    QString  *localViewName;
    QMap &lt;QString, ModulQuery&gt; *localTmpMap;

    QMessageBox msgBox;
signals:

public slots:
    void okPushed();
    void createQuery();
    void addToComboBox(const int &amp;CheckBoxName);

};

#endif // VIEWQUERRYOPTION_H
</code></pre>
<p>Hier der Code des Objektes &quot;ViewQuerryOption.cpp&quot;</p>
<pre><code>#include &quot;ViewQuerryOption.h&quot;

ViewQuerryOption::ViewQuerryOption(QWidget *parent) : QDialog(parent)
{
    //Erzeugung aller grafischen bestandteile des fensteres und verschachtelung in Layouts

    //Hinzufügen der Objete, deren Signale gebündelt werden
    signalMapper.setMapping(&amp;plz,1);
    signalMapper.setMapping(&amp;number,2);
    signalMapper.setMapping(&amp;city,3);
    signalMapper.setMapping(&amp;street,4);
    signalMapper.setMapping(&amp;firstName,5);
    signalMapper.setMapping(&amp;lastName,6);
    signalMapper.setMapping(&amp;male,7);
    signalMapper.setMapping(&amp;roll,8);
    signalMapper.setMapping(&amp;companyName,9);
    signalMapper.setMapping(&amp;phone,10);
    signalMapper.setMapping(&amp;mail,11);

    // Beschriftung der RadioButton
    rbInstanz.setText(&quot;Instanz / Person&quot;);
    rbFirma.setText(&quot;Firma&quot;);
    rbUser.setText(&quot;D-Manager Nutzer&quot;);

    // vertikales Layout für die Radiobutton in der oberen GroupBox
    vRadioL.addWidget(&amp;rbInstanz);
    vRadioL.addWidget(&amp;rbFirma);
    vRadioL.addWidget(&amp;rbUser);
    //Fügt der GroupBox das Layout mit den 3 RadioButton hinzu
    preSelect.setLayout(&amp;vRadioL);

    // Beschriftung der Labels
    addressData.setText(&quot;Adressdaten&quot;);
    instanzData.setText(&quot;Instanz / Personendaten&quot;);
    nextData.setText(&quot;weitere Informationen&quot;);
    contectData.setText(&quot;Kontaktdaten&quot;);
    nameOfView.setText(&quot;Name der View:&quot;);

    // Beschriftung der CheckBoxen
    street.setText(&quot;Strasse&quot;);
    number.setText(&quot;Hausnummer&quot;);
    plz.setText(&quot;Postleitzahl&quot;);
    city.setText(&quot;Stadt&quot;);
    male.setText(&quot;Anrede&quot;);
    lastName.setText(&quot;Nachname&quot;);
    firstName.setText(&quot;Vorname&quot;);
    companyName.setText(&quot;Firmenname&quot;);
    roll.setText(&quot;Instanzname&quot;);
    phone.setText(&quot;Telefon&quot;);
    mail.setText(&quot;E-Mail&quot;);

    // vertikales Layout für die Checkboxen zur Adresse
    vBoxLaddress.addWidget(&amp;addressData);
    vBoxLaddress.addWidget(&amp;street);
    vBoxLaddress.addWidget(&amp;number);
    vBoxLaddress.addWidget(&amp;plz);
    vBoxLaddress.addWidget(&amp;city);

    // vertikales Layout für die Checkboxen zur Instanz
    vBoxLinstanz.addWidget(&amp;instanzData);
    vBoxLinstanz.addWidget(&amp;male);
    vBoxLinstanz.addWidget(&amp;lastName);
    vBoxLinstanz.addWidget(&amp;firstName);

    // Horizontales Layout für die vertikalen Layouts der Checkboxen zur Adresse und Instanz
    hInAnL.addLayout(&amp;vBoxLinstanz);
    hInAnL.addLayout(&amp;vBoxLaddress);

    // vertikales Layout für die Checkboxen zur weiteren Daten
    vBoxLnext.addWidget(&amp;nextData);
    vBoxLnext.addWidget(&amp;companyName);
    vBoxLnext.addWidget(&amp;roll);

    // vertikales Layout für die Checkboxen zur Kontaktdaten
    vBoxLcontact.addWidget(&amp;contectData);
    vBoxLcontact.addWidget(&amp;phone);
    vBoxLcontact.addWidget(&amp;mail);

    // vertikales Layout für die Radiobutton in der mittleren GroupBox
    hNeCoL.addLayout(&amp;vBoxLnext);
    hNeCoL.addLayout(&amp;vBoxLcontact);

    // Fügt die 2 horizontalen layouts nochmal i ein vertikales zusammen
    vBoxLall.addLayout(&amp;hNeCoL);
    vBoxLall.addLayout(&amp;hInAnL);

    //Fügt der mittleren GroupBox das Layout mit den CheckBoxen hinzu
    selectViews.setLayout(&amp;vBoxLall);

    //Fügt den Comboboxen die Standard Auswahlmöglichkeiten hinzu
    whereSelect.addItem(&quot;Suche verfeinern&quot;);
    relation.addItem(&quot;=&quot;);
    relation.addItem(&quot;&lt;&quot;);
    relation.addItem(&quot;&gt;&quot;);

    // vertikales Layout für die untere Filtefunktion
    hWhereL.addWidget(&amp;whereSelect);
    hWhereL.addWidget(&amp;relation);
    hWhereL.addWidget(&amp;searcher);

    // fügt layout GroupBox hinzu
    selectWhere.setLayout(&amp;hWhereL);

    // Button vorbereiten
    ok.setText(&quot;OK&quot;);
    cancel.setText(&quot;Abbrechen&quot;);
    //Namenslabel und Funktionsbutten zu einem Layout formen
    hViewLabelL.addWidget(&amp;nameOfView);
    hViewLabelL.addWidget(&amp;nameOfV);
    hFunctionButtonL.addWidget(&amp;ok);
    hFunctionButtonL.addWidget(&amp;cancel);
    vButtonNemaL.addLayout(&amp;hViewLabelL);
    vButtonNemaL.addLayout(&amp;hFunctionButtonL);

    nameLabel.setLayout(&amp;vButtonNemaL);

    // Fügt die 3 Groupboxen eine horizontalen Layout hinzu
    hL.addWidget(&amp;preSelect);
    hL.addWidget(&amp;selectViews);
    vL.addLayout(&amp;hL);
    vL.addWidget(&amp;selectWhere);
    vL.addWidget(&amp;nameLabel);

    // Setzt das gesammte Layout
    setLayout(&amp;vL);

    QObject::connect(&amp;ok,SIGNAL(clicked()),this,SLOT(okPushed()));
    QObject::connect(&amp;cancel,SIGNAL(clicked()),this,SLOT(close()));

    //Immer wenn eine Checkbox angeklickt wurde und sich damit ihr Status geänder hatte wird diese CheckBox
    //in den Mappere geschrieben
    QObject::connect( &amp;plz, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;number, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;city, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;street, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;firstName, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;lastName, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;male, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;roll, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;companyName, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;phone, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );
    QObject::connect( &amp;mail, SIGNAL(clicked()), &amp;signalMapper, SLOT(map()) );

    QObject::connect(&amp;signalMapper, SIGNAL(mapped(const int&amp;)), this, SLOT(addToComboBox(const int &amp;)) );
}

ViewQuerryOption::~ViewQuerryOption()
{

}

//fügt die angehakten spalten zur ComboBox hinzu um diese weiter zu nutzen.
void ViewQuerryOption::addToComboBox(const int &amp;CheckBoxName)
{

    switch (CheckBoxName)
    {
    case 1 :
        if (plz.isChecked())
        {
            whereSelect.addItem(&quot;PLZ&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;PLZ&quot;));
        }
    break;
    case 2 :
        if (number.isChecked())
        {
            whereSelect.addItem(&quot;Hausnummer&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Hausnummer&quot;));
        }
    break;
    case 3 :
        if (city.isChecked())
        {
            whereSelect.addItem(&quot;Stadt&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Stadt&quot;));
        }
    break;
    case 4 :
        if (street.isChecked())
        {
            whereSelect.addItem(&quot;Strasse&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Strasse&quot;));
        }
    break;
    case 5 :
        if (firstName.isChecked())
        {
            whereSelect.addItem(&quot;Vorname&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Vorname&quot;));
        }
    break;
    case 6 :
        if (lastName.isChecked())
        {
            whereSelect.addItem(&quot;Nachname&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Nachname&quot;));
        }
    break;
    case 7 :
        if (male.isChecked())
        {
            whereSelect.addItem(&quot;Anrede&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Anrede&quot;));
        }
    break;
    case 8 :
        if (roll.isChecked())
        {
            whereSelect.addItem(&quot;Rolle&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Rolle&quot;));
        }
    break;
    case 9 :
        if (companyName.isChecked())
        {
            whereSelect.addItem(&quot;Firma&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Firma&quot;));
        }
    break;
    case 10 :
        if (phone.isChecked())
        {
            whereSelect.addItem(&quot;Telefon&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;Telefon&quot;));
        }
    break;
    case 11 :
        if (mail.isChecked())
        {
            whereSelect.addItem(&quot;E-Mail&quot;);
        }else
        {
            whereSelect.removeItem(whereSelect.findText(&quot;E-Mail&quot;));
        }
    break;

    }
}

void ViewQuerryOption::okPushed()
{
    if (nameOfV.text()==&quot;&quot;)
    {
        const wchar_t* QboxText = L&quot;Bitte geben Sie einen Namen für die neue Ansicht ein!\n&quot;;
        msgBox.setWindowTitle(&quot;Name fehlt&quot;);
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.setText(QString(QString::fromWCharArray(QboxText)));
        msgBox.exec();
    }else if(localTmpMap-&gt;contains(nameOfV.text()))
    {
        /*ModulQuery foo;
        foo = localTmpMap-&gt;value(nameOfV.text());
        cout &lt;&lt;&quot;Querry: &quot; &lt;&lt;foo.getQuery().toStdString() &lt;&lt;endl;
        */
        const wchar_t* QboxText = L&quot;Dieser Name existiert bereits! Bitte wählen Sie einen anderen.\n&quot;;
        msgBox.setWindowTitle(&quot;Name existiert&quot;);
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.setText(QString(QString::fromWCharArray(QboxText)));
        msgBox.exec();
    }else
    {
        this-&gt;createQuery();
        this-&gt;close();
    }

}
/*
 * Übernimmt die Zeiger auf den Querry und den Tabnamen auf Klasseenvariablen
 * und startet die View.
*/
void ViewQuerryOption::tableViewOption(QString *query, QString *viewName, QMap &lt;QString, ModulQuery&gt; *TqmStorage)
{
    makingQuery=query;
    localViewName=viewName;
    localTmpMap = TqmStorage;
    this-&gt;exec();
}

/*
 * Erstellt aus den ANgaben des Nutuzers einen gültigen SQL Query
*/
void ViewQuerryOption::createQuery()
{

    *makingQuery=&quot;SELECT&quot;;

    if (plz.isChecked())
    {*makingQuery=*makingQuery+&quot; plz,&quot;;}

    if (number.isChecked())
    {*makingQuery=*makingQuery+&quot; hausnummer,&quot;;}

    if (city.isChecked())
    {*makingQuery=*makingQuery+&quot; ort,&quot;;}

    if (street.isChecked())
    {*makingQuery=*makingQuery+&quot; strasse,&quot;;}

    if (firstName.isChecked())
    {*makingQuery=*makingQuery+&quot; vorname,&quot;;}

    if (lastName.isChecked())
    {*makingQuery=*makingQuery+&quot; nachname,&quot;;}

    if (male.isChecked())
    {*makingQuery=*makingQuery+&quot; anrede,&quot;;}

    if (roll.isChecked())
    {*makingQuery=*makingQuery+&quot; rollenname,&quot;;}

    if (companyName.isChecked())
    {*makingQuery=*makingQuery+&quot; firmenname,&quot;;}

    if (phone.isChecked())
    {*makingQuery=*makingQuery+&quot; telefonnummer, beschreibung,&quot;;}

    if (mail.isChecked())
    {*makingQuery=*makingQuery+&quot; mail,&quot;;}

    //löscht das letzte Komma bevor FROM geschrieben wird. SQL Fehler vermeiden!
     makingQuery-&gt;remove((makingQuery-&gt;length()-1),1);
    *makingQuery=*makingQuery+&quot; FROM&quot;;

    if (plz.isChecked() || number.isChecked() || city.isChecked() || street.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_anschrift,&quot;;}

    if (firstName.isChecked() || lastName.isChecked() || male.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_person,&quot;;}

    if (phone.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_phone,&quot;;}

    if (mail.isChecked())
    {*makingQuery=*makingQuery+&quot; dm_mail,&quot;;}

    //löscht das letzte Komma vor WHERE geschrieben wird. SQL Fehler vermeiden!
    makingQuery-&gt;remove((makingQuery-&gt;length()-1),1);

    if (whereSelect.currentText()==&quot;Suche verfeinern&quot;)
    {
    }else
    {
        *makingQuery=*makingQuery+&quot; WHERE &quot;;
        *makingQuery=*makingQuery+whereSelect.currentText();
        *makingQuery=*makingQuery+relation.currentText();
        *makingQuery=*makingQuery+&quot;'&quot;;
        *makingQuery=*makingQuery+searcher.text();
        *makingQuery=*makingQuery+&quot;'&quot;;

    }
    *localViewName=nameOfV.text();
}
</code></pre>
<p>BTW.: Ich arbeite hier mit der QT Bibliothek da es sich aber um Speicherfehler handelt dachte ich ein C++ Forum ist geeigneter. Ich weis es ist viel Code, das Meiste sind Form Objekte die in Layouts geschachtelt werden.</p>
<p>Ist die Funktion ein gängiger Workaround oder liegt da schon der Fehler begraben?</p>
<pre><code>void ViewQuerryOption::tableViewOption(QString *query, QString *viewName, QMap &lt;QString, ModulQuery&gt; *TqmStorage)
{
    makingQuery=query;
    localViewName=viewName;
    localTmpMap = TqmStorage;
    this-&gt;exec();
}
</code></pre>
<p>Vielen Dank schonmal für eure Hilfe!</p>
<p>Gruß Meho</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405216</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405216</guid><dc:creator><![CDATA[Meho]]></dc:creator><pubDate>Mon, 23 Jun 2014 13:07:32 GMT</pubDate></item><item><title><![CDATA[Reply to kaputter Heap: double free or corruption (out) beim löschen des Objektes on Mon, 23 Jun 2014 13:09:37 GMT]]></title><description><![CDATA[<p>Tja, hunderte Codezeilen, aber new und delete einfach nur aus dem Zusammenhang gerissen. Das ist ziemlich sinnlos.</p>
<p>Geraten: Qt löscht deine View schon, dein delete ist dann eins zu viel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405220</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 23 Jun 2014 13:09:37 GMT</pubDate></item><item><title><![CDATA[Reply to kaputter Heap: double free or corruption (out) beim löschen des Objektes on Mon, 23 Jun 2014 13:19:30 GMT]]></title><description><![CDATA[<p>Jepp, Qt löscht nach close():<br />
<a href="http://qt-project.org/doc/qt-5/qwidget.html#close" rel="nofollow">http://qt-project.org/doc/qt-5/qwidget.html#close</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405222</guid><dc:creator><![CDATA[oenone]]></dc:creator><pubDate>Mon, 23 Jun 2014 13:19:30 GMT</pubDate></item><item><title><![CDATA[Reply to kaputter Heap: double free or corruption (out) beim löschen des Objektes on Mon, 23 Jun 2014 13:33:48 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /><br />
Also auf der einen Seite bin ich über eure schnelle und kompetente Hilfe sehr beeindruckt und sehr dankbar!<br />
Auf der anderen Seite sucht, googelt und wühlt man an einem Fehler, stunden lang, den andere in nicht mal 5 min beantwortet haben! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
<p>Ich führe</p>
<pre><code>this-&gt;close();
</code></pre>
<p>in &quot;void ViewQuerryOption::okPushed()&quot; aus und erbe von QDialog also passt<br />
&quot;If the widget has the Qt::WA_DeleteOnClose flag, the widget is also deleted.&quot;</p>
<p>Vielen Dank für eure schnelle Hilfe!</p>
<p>BTW: Kann ich irgenwie nachvolziehen ob das Objekt gelöscht wurde im Debugger habe ich nichts gefunden, da sieht man nur den Stack.</p>
<p>Gruß Meho</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405226</guid><dc:creator><![CDATA[Meho]]></dc:creator><pubDate>Mon, 23 Jun 2014 13:33:48 GMT</pubDate></item><item><title><![CDATA[Reply to kaputter Heap: double free or corruption (out) beim löschen des Objektes on Mon, 23 Jun 2014 13:35:59 GMT]]></title><description><![CDATA[<p>Meho schrieb:</p>
<blockquote>
<p>BTW: Kann ich irgenwie nachvolziehen ob das Objekt gelöscht wurde im Debugger habe ich nichts gefunden, da sieht man nur den Stack.</p>
</blockquote>
<p>Haltepunkt oder Ausgabe im Destruktor</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405227</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 23 Jun 2014 13:35:59 GMT</pubDate></item><item><title><![CDATA[Reply to kaputter Heap: double free or corruption (out) beim löschen des Objektes on Mon, 23 Jun 2014 13:39:53 GMT]]></title><description><![CDATA[<p>Meho schrieb:</p>
<blockquote>
<p>Auf der anderen Seite sucht, googelt und wühlt man an einem Fehler, stunden lang, den andere in nicht mal 5 min beantwortet haben! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
</blockquote>
<p>Oft ist es leider andersrum, viele fragen einfach in Foren nach, ohne auch nur 2 min selbst nachzulesen oder google zu fragen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405229</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405229</guid><dc:creator><![CDATA[oenone]]></dc:creator><pubDate>Mon, 23 Jun 2014 13:39:53 GMT</pubDate></item><item><title><![CDATA[Reply to kaputter Heap: double free or corruption (out) beim löschen des Objektes on Mon, 23 Jun 2014 14:03:42 GMT]]></title><description><![CDATA[<p>Meho schrieb:</p>
<blockquote>
<p>Also auf der einen Seite bin ich über eure schnelle und kompetente Hilfe sehr beeindruckt und sehr dankbar!<br />
Auf der anderen Seite sucht, googelt und wühlt man an einem Fehler, stunden lang, den andere in nicht mal 5 min beantwortet haben! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
</blockquote>
<p>Das nennt man Erfahrung <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Erfahrung gewinnt man (auch), indem man Fehler macht!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2405240</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2405240</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 23 Jun 2014 14:03:42 GMT</pubDate></item></channel></rss>