Results 1 to 8 of 8

Thread: Handle QContextMenuEvent conflict

  1. #1
    Join Date
    Oct 2009
    Posts
    65
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Handle QContextMenuEvent conflict

    Good evening to all,
    I'm a newbie of qt and I need some help for a strange event that I found during the developing of my system
    I've create a two-level QTreeview (I've posted it in http://www.qtcentre.org/threads/4074...iew?highlight=) and I need to use the QContextMenuEvent on the two QTreeview, and create the menù on the using class (I don't want create a fixed menu for the two QTreeview, I need to be able to change the menu relative to each one). Now I left the default configuration (Qt:efaultContextMenu) and handled it in the using class (QMainWindow that use my control). It work fine in debugging mode, but in release mode ti failed given different errors:
    ASSERT failure in QMutexLocker: "QMutex pointer is misaligned", file ..\..\include/QtCore/../../src/corelib/thread/qmutex.h, line 100
    or
    Starting C:\TestQT\Hgrid\Hierarchical\hierarchical-build-desktop\debug\hierarchical.exe...
    ... exited with code -1073741819
    I think it could be a handling conflic of the two controls (I need to handle both of event; of the outher QTreeView but also the inner one), I tried to set the Qt::NoContextMenu policy but no better way (perhaps because I call the contextMenu on an object that isn't able to handle id?)

    I don't know how I can pass the event handling to the outher QTreeview or resolve in some way this problem

    Thanks for your time.

    I hope to hearing from you soon )

    Michele

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Handle QContextMenuEvent conflict

    Its sounds you have a memory problem, either you are writing out of bounds, or using a dangling pointer.
    Is your application threaded?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2009
    Posts
    65
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Handle QContextMenuEvent conflict

    No, I don't use thread. You can see the code of my control at this link http://www.qtcentre.org/threads/40744-Hierarchical-TreeView?highlight=

    Thanks for your help

    Michele

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Handle QContextMenuEvent conflict

    See if these asserts fire:
    Qt Code:
    1. void TableDelegate::setHideColumn(int column)
    2. {
    3. Q_ASSERT(column < 30);
    4. colshided[column]=1;
    5. }
    6.  
    7. void TableDelegate::setShowColumn(int column)
    8. {
    9. Q_ASSERT(column < 30);
    10. colshided[column]=0;
    11. }
    12.  
    13. void InternalTableDelegate::setHideColumn(int column)
    14. {
    15. Q_ASSERT(column < 30);
    16. colshided[column]=1;
    17. }
    18.  
    19. void InternalTableDelegate::setShowColumn(int column)
    20. {
    21. Q_ASSERT(column < 30);
    22. colshided[column]=0;
    23. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Oct 2009
    Posts
    65
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Handle QContextMenuEvent conflict

    Dear high_flyer,
    I added your code to the mine, and I isolated the HGrid component to the other software, creating a new small project that I attach.
    If I request the context menu (in release mode or run debug mode) rapidly to the different QTreeView (outher and inner) and click onto the menu appared, after some click I obtain the "errore.png" window, I think relative to one of Q_Assert that I inserted. To know which of the 4 assert rised, i try to click "Debug with QTCreator" but I got the "nodebug.png" error dialog.
    Other time, I got the "QMutex..." error that I post in previous posts yet, with "errQMutex.png" error dialog.

    What else I should check?

    Thanks a lot for your time.

    Michele
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Handle QContextMenuEvent conflict

    I think relative to one of Q_Assert that I inserted.
    If the assert is caught, the message will contain the file and line number of the assert which caused the break.

    Since you made a test project, and since it is crashing, just run it in a debugger, and see which line is crashing.

    As I said in my first post, it looks like you are writing out of bounds, probably to your int array.
    So have a look in your code to all the places where you reference that array, and make sure you surround that code with a check, so that you don't reference it outside its bounds.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Oct 2009
    Posts
    65
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Handle QContextMenuEvent conflict

    Thansk a lot high_flyer, but... which debugger? If I run my project by "Start debugging (F5)" from QTCreator, it no crash! How can I see the line code?
    In one run of start debugging, it wrote:
    Heap corruption detected at 00B33388
    Heap corruption detected at 00B33388
    Heap [hierarchical.exe]:
    Heap: Free heap block b33380 modified at b33390 after it was freed.

    ..... exited with code 1073807364
    Is there any other then I should check?

    Thanks a lot for your time.

    I'll check my code on that array

    thanks.

    Michele

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Handle QContextMenuEvent conflict

    Ok, the problem as the debugger is saying, is a heap corruption, not a stack.
    You are either reallocating memory on pointer that you haven't freed AND/OR doing some pointer arithmetic which is corrupting the pointer.
    Make sure you free all the pointers you are allocating on the heap, and test the pointer for validity before using it.
    Setting pointers to NULL when ever not initialized is recommended as well.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 1
    Last Post: 22nd February 2011, 22:54
  2. Replies: 0
    Last Post: 20th January 2010, 19:51
  3. MinGW conflict?
    By Paolo_R in forum Newbie
    Replies: 3
    Last Post: 30th June 2009, 05:16
  4. QContextMenuEvent appear on mouse release
    By bucksey in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2009, 01:09
  5. Framebuffer conflict
    By Vidar Bøe in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 21st November 2008, 10:33

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.