Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: very strange behaviour

  1. #1
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Thumbs down very strange behaviour

    Hi,

    I'm develloping a GPL application and for the last weeks I have noticed a very strange behaviour of my application. I'm using kdevelop to write the code.
    I have added a screenshot of the strange fact that although during the debuggingsession you can see tha the value of the variable is false, during testing in an if construction, execution goes on inside the if construction. It's a pity that I can't post a bigger screenshot (limitations of this forum).
    What is going on, the laws of physics seem broken.

    Regix
    Attached Images Attached Images

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

    Default Re: very strange behaviour

    Did you check the value during runtime? Maybe there it is true and not false? Maybe you have some uninitialised variable somewhere which causes a random value during runtime and is zeroed while under debugger?

  3. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: very strange behaviour

    heh, I hate when physics is broken.
    maybe the executable code is out of sync? do a full clean rebuild? maybe the wrong dll/debug symbols is being loaded?
    maybe there's a background thread running? but that would take some really weird timing.
    can you look at the assembly code that is being run? maybe that might give a hint.
    Software Engineer



  4. #4
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    Thanks for replying,

    I have put a qDebug() statement in the method, but that doesn't show up in the output also.
    It seems as my code is getting randomly executed. I will check for the variables to see if they are all initialized. About the assemblycode: How does one look at the assemblycode?

    Rgx

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

    Default Re: very strange behaviour

    Quote Originally Posted by regix
    I have put a qDebug() statement in the method, but that doesn't show up in the output also.
    Is the application compiled in debug mode?

  6. #6
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    No, in Release mode with Enable warnings,
    should I compile it in Debug mode?

  7. #7
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    I changed the project options in kdevelop to compile in debug mode

    g++ -c -pipe -O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -Wall -W -g -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -I/usr/lib/qt3/mkspecs/default -I. -I/usr/include/Magick++ -I/usr/include/magick -I/usr/include -I/usr/lib/qt3/include -o dlgtexteffect.o dlgtexteffect.cpp

    this is part of the output: it seems to me that NO_DEBUG is still active and the application is still build in release mode??

    Rgx

  8. #8
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: very strange behaviour

    LOL, I'm surprised you could even step through code in release mode.
    Software Engineer



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

    Default Re: very strange behaviour

    Quote Originally Posted by regix
    this is part of the output: it seems to me that NO_DEBUG is still active and the application is still build in release mode??
    If you didn't forget to run qmake after the change in the project file, then it's ok. How does the application behave now? Can you, for example set a breakpoint in the troublesome code and step through it monitoring the behaviour?

  10. #10
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    Qt Code:
    1. # File generated by kdevelop's qmake manager.
    2. # -------------------------------------------
    3. # Subdir relative project main directory: ./src
    4. # Target is an application:
    5.  
    6. LIBS += -lMagick \
    7. -lMagick++
    8. INCLUDEPATH += /usr/include/Magick++ \
    9. /usr/include/magick
    10. CONFIG += debug \
    11. warn_on \
    12. qt
    13. TEMPLATE = app
    14. FORMS += backgrounddlg.ui \
    15. CreateDialogBase.ui \
    16. dlgCSS.ui \
    17. dlgTextEffectBase.ui \
    18. dlgTextForAllBase.ui \
    19. EditCSSDlgBase.ui \
    20. MagickFontDlg.ui \
    21. ThemeBase.ui \
    22. websitedialog.ui
    23. HEADERS += BackGroundDlgImpl.h \
    24. createdialog.h \
    25. css.h \
    26. dlgcssimpl.h \
    27. dlgtexteffect.h \
    28. dlgtextforall.h \
    29. editcssdlg.h \
    30. htmlgenerator.h \
    31. htmlpage.h \
    32. listviewbackground.h \
    33. magickfontdlgimpl.h \
    34. mysettings.h \
    35. myspeciallabel.h \
    36. mystatuslabel.h \
    37. saxhandler.h \
    38. texteffect.h \
    39. theme.h \
    40. themeimpl.h \
    41. thumbnailgenerator.h \
    42. websitedialogimpl.h
    43. SOURCES += BackGroundDlgImpl.cpp \
    44. createdialog.cpp \
    45. css.cpp \
    46. dlgcssimpl.cpp \
    47. dlgtexteffect.cpp \
    48. dlgtextforall.cpp \
    49. editcssdlg.cpp \
    50. htmlgenerator.cpp \
    51. htmlpage.cpp \
    52. listviewbackground.cpp \
    53. magickfontdlgimpl.cpp \
    54. mysettings.cpp \
    55. myspeciallabel.cpp \
    56. mystatuslabel.cpp \
    57. saxhandler.cpp \
    58. texteffect.cpp \
    59. theme.cpp \
    60. themeimpl.cpp \
    61. thumbnailgenerator.cpp \
    62. websitecreator.cpp \
    63. websitedialogimpl.cpp
    To copy to clipboard, switch view to plain text mode 

    This is my .pro file.
    I ran qmake followed by make.
    Although debug is marked in the pro file during compilation g++ uses -D NO_DEBUG
    I am able to put a breakpoint in the sourcecode but unable to debug it.

    Rgx

  11. #11
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    After a second look:

    I am actually able to debug the application. It just didnt stop at the second breakpoint. As I can see now several of my bool variables have a numerical value???
    I will have a look at the constructor where I give a value to them.

    Rgx


  12. #12
    Join Date
    Mar 2006
    Posts
    10
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: very strange behaviour

    I dont understand how that code evne compiles, since when is
    Qt Code:
    1. if (condition1 and condition2) {}
    To copy to clipboard, switch view to plain text mode 

    valid C++ ?

    I thought it should be
    Qt Code:
    1. if (condition1 && condition2) {}
    To copy to clipboard, switch view to plain text mode 

  13. #13
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    yes I know, I've tried both and it looks that both compile. The strange thing about my code is: I put a QMessageBox statement in a constructor that gets executed and the code compiles but doesn't get executed. Nothing I change in the code gets executed!!!
    It's driving me nuts!

    Rgx

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

    Default Re: very strange behaviour

    Try cleaning your build and rebuilding the application from scratch (make distclean && qmake && make).

  15. #15
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    I have made a new project with kdevelop on a fresh suse 10.0 installation. I imported only the sourcefiles, headers and ui files. I added the config macros and the libs and includes in the pro file, I ran qmake and it issued warnings about possible symbol conflicts in a lot of sourcefiles. I tried to build the project: no luck. I tried to build the subproject (what is the difference between a project and subproject??) and it compiled all the sourcefiles but failed to link the application properly

    On the computer where the app is still compiling I ran make distclean in the src directory
    It replied no rule to make or something like that probably because I removed all the .o files as well as the moc* files as well as the Makefile. So I ran qmake and in kdev I chose for build project and it compiled and linked fine. When I chose start debug, the application started but jumped over the breakpoint I had put in a constructor that is executed.

    ????
    Rgx

  16. #16
    Join Date
    May 2006
    Posts
    28
    Thanks
    8
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: very strange behaviour

    perhaps you could try compiling with the -g and -O0, so no optimisations.
    This would help when debugging, the lines dont jump around seemingly random.

    And then put a watch for the variable so the debugger stops at it, or when it changes.

  17. #17
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    no effect after compiling with O0

    Rgx

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

    Default Re: very strange behaviour

    Quote Originally Posted by regix
    I have made a new project with kdevelop on a fresh suse 10.0 installation. I imported only the sourcefiles, headers and ui files. I added the config macros and the libs and includes in the pro file, I ran qmake and it issued warnings about possible symbol conflicts in a lot of sourcefiles. I tried to build the project: no luck. I tried to build the subproject (what is the difference between a project and subproject??) and it compiled all the sourcefiles but failed to link the application properly
    Did you clean all the temporary files (especially ones that moc created) before moving them to the new project?

  19. #19
    Join Date
    Jan 2006
    Posts
    45
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: very strange behaviour

    I went into the src directory and did
    rm *.o
    rm moc*
    rm Makefile

    Are there any more files I should delete?

    Rgx

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

    Default Re: very strange behaviour

    Try running 'make clean' or even 'make distclean'.

Similar Threads

  1. QComboBox +SUSE10.0 +qt4.1 strange behavior
    By antonio.r.tome in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2006, 18:49
  2. Setting behaviour in designer
    By Morea in forum Qt Tools
    Replies: 3
    Last Post: 19th March 2006, 16:33
  3. Different behaviour on different distributions
    By Kumula in forum Qt Programming
    Replies: 17
    Last Post: 7th March 2006, 00:58
  4. Replies: 1
    Last Post: 26th February 2006, 06:52
  5. [Qt 4.1] Strange behaviour with QTableView
    By fane in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2006, 07:17

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.