Results 1 to 6 of 6

Thread: Program Crash

  1. #1

    Default Program Crash

    Hi all,
    I have implemented a C++ function that uses a C library. I have no problem if i call it from main but when i call it whitin a QWidget the program crashes.
    Any help?
    Thanks

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Program Crash

    check line 45 in your source.
    no, seriously provide more information and code.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3

    Default Re: Program Crash

    ok
    the function i have to call il
    Qt Code:
    1. void run()
    2. {
    3. MesDomain *domain;
    4. domain=new MesDomain();
    5. std::vector<MesPoint> p;
    6. std::vector<MesEndPoints> s;
    7. std::vector<MesPoint> v;
    8. ...
    9. domain->setPolygon(p,s,h);
    10. domain->computeQuadrangulation();
    11. ...
    12. delete domain
    13. }
    To copy to clipboard, switch view to plain text mode 

    here is class MesDomain

    Qt Code:
    1. class MesDomain
    2. {
    3. private:
    4. MesPolygon *polygon;
    5. MesNodes *nodes;
    6. MesEdges *edges;
    7. MesElements *elements;
    8. CQMesh *mesh;
    9.  
    10. public:
    11. MesDomain();
    12. ~MesDomain();
    13.  
    14. void setPolygon(std::vector<MesPoint>, std::vector<MesEndPoints>, std::vector<MesPoint> );
    15. void computeQuadrangulation();
    16. void saveQuadrangulation(std::string);
    17.  
    18. private:
    19. void computeTriangulation(triangulateio *);
    20. };
    To copy to clipboard, switch view to plain text mode 

    and its methods:
    Qt Code:
    1. void MesDomain::setPolygon(std::vector<MesPoint> v, std::vector<MesEndPoints> s, std::vector<MesPoint> h) {
    2. for (std::vector<MesPoint>::iterator it=v.begin(); it!=v.end(); ++it) polygon->addVertex(*it);
    3. for (std::vector<MesEndPoints>::iterator it=s.begin(); it!=s.end(); ++it) polygon->addSegment(*it);
    4. for (std::vector<MesPoint>::iterator it=h.begin(); it!=h.end(); ++it) polygon->addHole(*it);
    5. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MesDomain::computeQuadrangulation() {
    2.  
    3. triangulateio *triangulation;
    4. triangulation = new triangulateio;
    5. ...
    6. computeTriangulation(triangulation);
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MesDomain::computeTriangulation(triangulateio *out) {
    2.  
    3. triangulateio in;
    4. ...
    5. char * opt = ...;
    6. triangulate(opt, &in, out, 0);
    7. }
    To copy to clipboard, switch view to plain text mode 

    and triangulateio and triangulate are defined in the C library

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Program Crash

    put a break point and check all variables. maybe some of pointers are equal to "0".
    Qt Code:
    1. void MesDomain::computeTriangulation(triangulateio *out) {
    2.  
    3. triangulateio in;
    4. ...
    5. char * opt = ...;//<--- put a break point here
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Program Crash

    Quote Originally Posted by jonmatteo View Post
    I have no problem if i call it from main but when i call it whitin a QWidget the program crashes.
    After you call "delete domain" in run() you maybe try to access any variable/function of that class? This would explain, why in main() you don't get an error, since there you don't delete it (of just leave the application afterward).

  6. #6

    Default Re: Program Crash

    thank you all
    I cant get what was the problem but now i can run it
    probably some empty pointer
    Thanks

Similar Threads

  1. Replies: 28
    Last Post: 9th March 2010, 08:59
  2. QListWidgetItem subclass - Crash program in drag/drop
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2009, 09:24
  3. Program crash when a signal is emitted
    By croscato in forum Qt Programming
    Replies: 7
    Last Post: 22nd November 2008, 22:24
  4. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  5. Crash: using a dialog in a model
    By Brandybuck in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2006, 01:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.