Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Internal error: pc 0x0 in read in psymtab, but not in symtab.



  • I get this error at many places in my GUI CAD application. On searching various forums or like the thread here... http://qt-project.org/forums/viewthread/16634, I could understand that this error is because of improper memory management. The result that I have is also same, the program works in debug mode giving this error but crashes when run in release mode.
    What I dont understand here in my perspective is how to do proper memory management. Following are more details about my problem.

    1. The application is a CAD application where all the items being drawn on the Scene are QPainterPaths subclassed items with various other properties.
    2. In discussion is a QUndoCommand which I am using for distributing the selected items "Equal Top Distance".
      The header and C Source is given here.
      The Header File:
      @#ifndef DISTRIBUTEENTITIESCMD_H
      #define DISTRIBUTEENTITIESCMD_H

    #include <QUndoCommand>
    #include <QWidget>
    #include "linecurvepathitem.h"
    #include "mymainview.h"

    bool topsort(basegraphicentity* e1, basegraphicentity* e2);

    class distributeentitiescmd : public QUndoCommand
    {
    public:
    distributeentitiescmd(mymainview *thisview,int mode,QUndoCommand *parent=0);

    void undo();
    void redo();
    

    private:
    mymainview *myGraphview; // pointer to the graphics view.
    mymainscene *myGraphscene; // pointer to the graphics scene.
    int mymode; // mode of working (1 = distribute equal tops)
    QList<basegraphicentity *> mylist; // This list saves the pointers of selected items in the scene.
    QList<QPainterPath> myoldpath,mynewpath; // lists for saving old and new values of path.
    qreal first,last,change,tempval,inchw;

    };

    #endif // DISTRIBUTEENTITIESCMD_H
    @

    The CPP File.
    @#include "distributeentitiescmd.h"

    distributeentitiescmd::distributeentitiescmd(mymainview *thisview, int mode, QUndoCommand *parent)
    :myGraphview(thisview),myGraphscene(thisview->sceneobject),mymode(mode),
    QUndoCommand(parent)
    {
    mylist.clear();
    myoldpath.clear();
    mynewpath.clear();
    if(mode==1) // Distribute Top
    {
    foreach(QGraphicsItem *myitem,myGraphscene->selectedItems())
    {
    if(basegraphicentity *myGraphitem = dynamic_cast<basegraphicentity *>(myitem))
    mylist.append(myGraphitem);
    }
    qSort(mylist.begin(),mylist.end(),topsort);
    first= mylist.first()->TopLeft().y();
    last = mylist.last()->TopLeft().y();
    change = (last - first) / (mylist.count()-1);
    for(int i = 0;i<mylist.count();++i)
    {
    myoldpath.append(mylist.at(i)->path());
    QTransform mytrans;
    tempval = mylist.at(i)->TopLeft().y();
    tempval = (first + (change * i) - tempval);
    mytrans.translate(0,tempval);
    mynewpath.append(mytrans.map(myoldpath.at(i)));
    }
    }
    }

    void distributeentitiescmd::undo()
    {
    for(int i = 0;i<myoldpath.count();++i)
    {
    mylist.at(i)->setSelected(false);
    mylist.at(i)->setPath(myoldpath.at(i));
    }
    myGraphscene->update();
    }

    void distributeentitiescmd::redo()
    {
    for(int i = 0;i<myoldpath.count();++i)
    {
    mylist.at(i)->setSelected(false);
    mylist.at(i)->setPath(mynewpath.at(i));
    }
    myGraphscene->update();
    }

    bool topsort(basegraphicentity *e1, basegraphicentity *e2)
    {
    qreal y1=e1->TopLeft().y(),y2=e2->TopLeft().y();
    return (y1<y2);
    }
    @

    Here, If I run this routine in Debug mode, everything runs fine. however, I get this error.
    Can someone suggest how to ensure proper memory management in this.


Log in to reply