Results 1 to 4 of 4

Thread: Project not showing/crashing when adding a simple line of code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2021
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Project not showing/crashing when adding a simple line of code

    Hello all, I'm trying to make a project which includes a square matrix of objects and for each entry I want to add a list of neighbours which are the 8 surrounding cells (cells on the edge of the matrix will connect to the other side, so each cell should have 8 neighbours). I have this piece of code:

    Qt Code:
    1. int i;
    2. int j;
    3.  
    4. for (i = 0; i<NCOL; i++) {
    5. for (j = 0; j<NCOL; j++) {
    6. mat[i][j].neigh.push_back(mat[(i-1+NCOL)%NCOL][(j-1+NCOL)%NCOL]);
    7. //mat[i][j].neigh.push_back(mat[i][(j-1+NCOL)%NCOL]);
    8. mat[i][j].neigh.push_back(mat[(i+1)%NCOL][(j-1+NCOL)%NCOL]);
    9. mat[i][j].neigh.push_back(mat[(i-1+NCOL)%NCOL][j]);
    10. mat[i][j].neigh.push_back(mat[(i+1)%NCOL][j]);
    11. mat[i][j].neigh.push_back(mat[(i-1+NCOL)%NCOL][(j+1)%NCOL]);
    12. mat[i][j].neigh.push_back(mat[i][(j+1)%NCOL]);
    13. mat[i][j].neigh.push_back(mat[(i+1)%NCOL][(j+1)%NCOL]);
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    Now, with this piece of code the project runs fine, however when I uncomment the second line of the loop, the project won't run...
    Sometimes, it crashes imediately, sometimes it says in the application output that the app is starting and it just stays that way until I force quit it, I had both error 1 and error 3 and for twice now I had my pc restarting while waiting for the mainwindow to show up. I even had those errors claiming I don't have permission.
    I really do not understand what is going on here

    I realized that when trying to run the app with the uncommented line, qt takes about 90% of my computer memory, but I don't know if this is part of the problem since a little line of code should not be such a problem.

    I would really appreciate if anyone knows what is happening as I cannot advance in my project until I solve this problem.
    Last edited by d_stranz; 24th July 2021 at 17:14. Reason: missing [code] tags

Similar Threads

  1. [UWP, Qt 5.10] App crashing everytime before showing drop down menu
    By BryanTriana in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 19th March 2018, 14:20
  2. Replies: 2
    Last Post: 11th July 2013, 18:48
  3. QTableWidget showing white line
    By deepal_de in forum Qt Programming
    Replies: 6
    Last Post: 25th May 2011, 10:06
  4. program crashing randomly code -1073741819
    By feraudyh in forum General Programming
    Replies: 6
    Last Post: 21st September 2010, 18:07
  5. Qt is crashing when showing this tooltip. Why?
    By kalos80 in forum Qt Programming
    Replies: 16
    Last Post: 27th July 2010, 11:05

Tags for this Thread

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.