Results 1 to 5 of 5

Thread: Crash when I fill the vector

  1. #1
    Join Date
    Nov 2012
    Location
    Russia
    Posts
    231
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Crash when I fill the vector

    Hello

    I have crash in the construction Scene::Scene() https://github.com/8Observer8/ObjLoader_v1_0_0

    You should run my application -> Click "Load" -> Select the file "Plane.observerFormat"

    I think that I cannot fill std::vector like this:

    Qt Code:
    1. #include <iostream>
    2. #include <vector>
    3.  
    4. void fill( std::vector<float> &vec1, std::vector<float> &vec2 );
    5. void show( const std::vector<float> &vec );
    6.  
    7. int main()
    8. {
    9. std::vector<float> vec1;
    10. std::vector<float> vec2;
    11. fill( vec1, vec2 );
    12.  
    13. show( vec1 );
    14. std::cout << "\n";
    15. show( vec2 );
    16.  
    17. return 0;
    18. }
    19.  
    20. void fill( std::vector<float> &vec1 , std::vector<float> &vec2 )
    21. {
    22. vec1.push_back( -0.5f );
    23. vec1.push_back( 0.5f );
    24. vec1.push_back( 1.5f );
    25.  
    26. vec2.push_back( 0.5f );
    27. vec2.push_back( 0.5f );
    28. vec2.push_back( 1.5f );
    29. }
    30.  
    31. void show( const std::vector<float> &vec )
    32. {
    33. for( unsigned int i = 0; i < vec.size(); ++i )
    34. {
    35. std::cout << vec[i] << "/n";
    36. }
    37. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Crash when I fill the vector

    The code you posted seems fine and should work without crashes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Nov 2012
    Location
    Russia
    Posts
    231
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Crash when I fill the vector

    Thank you for your attention. But I don't understand. I wrote another example. It crashes too on this line:

    Qt Code:
    1. qDebug() << m_cube.vertices.size();
    To copy to clipboard, switch view to plain text mode 

    Please, run it: https://github.com/8Observer8/CubeFromBlender_v1.0.1

    P.S. The file "Cube.observerFormat" must be lie in the "currentPath" folder

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Crash when I fill the vector

    Show us the backtrace please, I will not analyze your whole application.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    8Observer8 (21st December 2014)

  6. #5
    Join Date
    Nov 2012
    Location
    Russia
    Posts
    231
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Crash when I fill the vector

    Thank you! Chris Kawa solved my problem: http://qt-project.org/forums/viewthread/51212/

Similar Threads

  1. Copying vector of pointers to another vector
    By Momergil in forum Newbie
    Replies: 12
    Last Post: 24th September 2011, 23:09
  2. Replies: 1
    Last Post: 9th May 2011, 16:19
  3. vector causing system error/crash
    By babygal in forum Newbie
    Replies: 9
    Last Post: 21st October 2010, 08:48
  4. vector of vector and computes
    By mickey in forum General Programming
    Replies: 1
    Last Post: 15th May 2008, 13:47
  5. insert in a vector of vector
    By mickey in forum General Programming
    Replies: 3
    Last Post: 6th March 2007, 09:45

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.