Results 1 to 18 of 18

Thread: Application is fully functional ONLY on my laptop

  1. #1
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Application is fully functional ONLY on my laptop

    Application is fully functional only on my laptop, and on other computers it fails with part of its functionality.
    It starts on every computer (windows 64- and 32- bit), and some parts of it can be executed, but problem is the main part.
    I suspect problem is here, within sorting elements of QList.


    Qt Code:
    1. for(events_it = eventi.begin(); events_it!=eventi.end(); events_it++) {
    2. temp_event = *events_it;
    3. //if type==0, we access size of the event above, and set it to this event
    4. if(temp_event->getType() == 0) {
    5. Event *temp_event2;
    6. events_it2 = events_it;
    7. events_it2--;
    8. temp_event2 = *events_it2;
    9. long s = temp_event2->getSize();
    10. temp_event->setSize(s);
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 


    These are iterators i use:
    Qt Code:
    1. QList<Event*>::iterator events_it;
    2. QList<Event*>::iterator events_it2;
    To copy to clipboard, switch view to plain text mode 



    This is list i use:
    Qt Code:
    1. QList<Event*> eventi;
    To copy to clipboard, switch view to plain text mode 

    Object Event, which is inside QList:
    Qt Code:
    1. class Event
    2. {
    3. public:
    4. // Constructors
    5. Event(long a, long s, long t,short tip);
    6. Event(long a, long t, short tip);
    7.  
    8. private:
    9. long address;
    10. long size;
    11. long time;
    12. short type;
    13. };
    To copy to clipboard, switch view to plain text mode 


    Application is written under Windows 7 Professional (64-bit).

    Build settings:
    buildsettings.jpg

  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: Application is fully functional ONLY on my laptop

    What kind of incorrect behaviour do you observe?
    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
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    If you want to summarize the work of my application..
    1) it reads xml, parse it and save into list of Events, then sort this list, calculate points from sorted events, save it to binary file and finally plots the graph from calculated points

    OR

    2) if there is already binary file created during case 1), points are read from binary file and drawn as graph.


    So, on my laptop, app works in both cases of use, but on other computers it can only read correct binary (case 2), but cannot perform case1.
    Some steps of case 1 are incorrect, in my opinion, it fails during sorting..

  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: Application is fully functional ONLY on my laptop

    How did you implement sorting?
    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. #5
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    1st code snippet from 1st post - here's problem, its ok on my laptop and on other computers it fails..

  6. #6
    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: Application is fully functional ONLY on my laptop

    I don't see sorting in there.
    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.


  7. #7
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    sorry, firstly i use QStableSort to sort the list, and then this code snippet to access size property of Event (list element).
    Iteration through list is implemented with iterators and for loop, firstly it finds element with property type == 0, then with other iterator it goes up for one position and gets size property from above element and finally sets that size to first iterator (with type==0).

    I didn't mention usage of QStableSort - it goes well, i checked. But problems appear in code i pasted here.

  8. #8
    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: Application is fully functional ONLY on my laptop

    Quote Originally Posted by juracist View Post
    sorry, firstly i use QStableSort to sort the list,
    What comparison function are you using? Please show us the exact call to qStableSort along with the lessThan implementation you use with it.
    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.


  9. #9
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    Qt Code:
    1. qStableSort(eventi.begin(),eventi.end(),sortAddress);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. bool sortAddress(Event *left, Event *right){
    2. return (left->getAddress() < right->getAddress());
    3. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    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: Application is fully functional ONLY on my laptop

    And what your first code snippet is meant to do? Because it seems it searches for event of type 0 and then assigns it the value of "size" of a previous item. Which by the way will fail immediately if the first element in the list has type = 0.
    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.


  11. #11
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    If you have patience and time, download exe file of my app, and try to run it (only for windows )
    Application

    Then, open xml file from same folder, and, if everything is ok, graph should be drawn..
    .bin file will be created in same folder, but not good file, only with couple of nulls..
    I also attached bin file that is created under my enviroment and if you try to open it, it should draw graph..

    So, you'll see there is a problem only with reading xml file, not bin file.
    Steps while drawing graph from xml is following:
    1. parsexml - OK
    2. sortAddress - OK
    3. getSize(code snippet from above) - FAIL (checked by printing elements from list into text file)
    4. sortTime
    5. correctOrder (something like getSize)
    6. calculatePoints (create points from CORRECT list of elements)
    7. drawGraph

  12. #12
    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: Application is fully functional ONLY on my laptop

    Sorry, Linux user here Still, my question about what your code snippet is meant to do remains unanswered.
    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.


  13. #13
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    It does exactly what you wrote above. Only, problem isn't first element's property type=0, because it is 1 for sure.

    Here is whole sorting process, i dont know, maybe problem is somewhere else:
    Qt Code:
    1. if(!fileSorted){
    2. qStableSort(eventi.begin(),eventi.end(),sortAddress);
    3.  
    4. QList<Event*>::iterator events_it;
    5. QList<Event*>::iterator events_it2;
    6.  
    7. for(events_it = eventi.begin(); events_it!=eventi.end(); events_it++) {
    8. temp_event = *events_it;
    9. if(temp_event->getType() == 0) {
    10. Event *temp_event2;
    11. events_it2 = events_it;
    12. events_it2--;
    13. temp_event2 = *events_it2;
    14. long s = temp_event2->getSize();
    15. temp_event->setSize(s);
    16. }
    17. }
    18.  
    19. qStableSort(eventi.begin(),eventi.end(),sortTime);
    20.  
    21. for(events_it=eventi.begin(); events_it!=eventi.end(); events_it++) {
    22. temp_event = *events_it;
    23. events_it2 = events_it;
    24. events_it2++;
    25. if(events_it2!=eventi.end()) {
    26. Event *temp_event2 = *events_it2;
    27. if(temp_event->getTime() == temp_event2->getTime()) {
    28. if((temp_event->getType() == 1) && (temp_event2->getType() == 0)) {
    29. *events_it = temp_event2;
    30. *events_it2 = temp_event;
    31. }
    32. }
    33. }
    34. }
    35. }
    To copy to clipboard, switch view to plain text mode 

  14. #14
    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: Application is fully functional ONLY on my laptop

    Your first loop can be replaced with a simpler one:

    Qt Code:
    1. const s = eventi.size();
    2. for(int i=1;i<s;++i) {
    3. if(eventi[i]->getType() == 0) eventi[i]->setSize(eventi[i-1]->getSize());
    4. }
    To copy to clipboard, switch view to plain text mode 

    Your second loop, can be replaced with the following:
    Qt Code:
    1. for(int i=0;i<s-1;++i) {
    2. if((eventi[i]->getTime() == eventi[i+1]->getTime()) && (eventi[i]->getType() ==1) && (eventi[i+1]->getType() == 0)) qSwap(*eventi[i], *eventi[i+1]); // optionally you might need to ++i here
    3. }
    To copy to clipboard, switch view to plain text mode 

    The problem might be in my inlined comment. Since I don't know what you are trying to achieve with the above code, it is hard for me to say whether it is correct or not. I would suggest to get rid of all those iterators in favour of indexes to make sure incorrect use of iterators doesn't influence the result.
    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.


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

    juracist (24th June 2012)

  16. #15
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    Thank you very, very much!!! ))))
    You don't know how important it is to me, it was driving me crazy for days!
    Problem was that i taken some parts of code from previous version (which wasn't in Qt), assuming it'll work as before.

    But now i have another question (since I know you're linux user ).
    What do I do to make this app usable on linux too?
    It shouldnt be so hard since Qt is supposed to enable portability and platform independence?

    Once again, thanks man!!!

  17. #16
    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: Application is fully functional ONLY on my laptop

    Quote Originally Posted by juracist View Post
    Thank you very, very much!!! ))))
    You don't know how important it is to me, it was driving me crazy for days!
    Problem was that i taken some parts of code from previous version (which wasn't in Qt), assuming it'll work as before.
    So it works now? What was the problem?


    But now i have another question (since I know you're linux user ).
    What do I do to make this app usable on linux too?
    It shouldnt be so hard since Qt is supposed to enable portability and platform independence?
    In theory you just need to [cross]compile it for Linux but it really depends on if you used any non-portable code in your program.
    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.


  18. #17
    Join Date
    Apr 2012
    Posts
    21
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Application is fully functional ONLY on my laptop

    I just changed my old code with that you wrote here, tried on my laptop - it worked, then on PC - surprise, it works for the first time on other computer )
    It seems these iterators or something was problem..
    Tomorrow I'll test it on couple of other computers to see if this is really working..

  19. #18
    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: Application is fully functional ONLY on my laptop

    I suspect this was wrong:

    Qt Code:
    1. *events_it = temp_event2;
    2. *events_it2 = temp_event;
    To copy to clipboard, switch view to plain text mode 
    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.


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

    juracist (25th June 2012)

Similar Threads

  1. installing and configuring Qt on a laptop running Ubuntu 12.04
    By modoMojo in forum Installation and Deployment
    Replies: 5
    Last Post: 20th June 2012, 09:29
  2. problem using qt mobility with my laptop camera
    By eyaler in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th May 2012, 18:40
  3. Replies: 0
    Last Post: 31st March 2011, 18:50
  4. Need to show a menu item with disabled look but functional
    By lalesculiviu in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2009, 15:16
  5. Fully qualified X font name
    By piotrek in forum Qt Programming
    Replies: 0
    Last Post: 26th March 2009, 15:16

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.