Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74697

QCheckBox: In some circonstances the signal stateChanged(int) is not raised when the box is (un)checked

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • None
    • Visual Studio 2017 
      Qt VS Tools

    Description

      Hi, this bug is not easy to catch, I failed to create a simple project where to catch the bug. So, I tried to simplify to the minimum my current project on which I catched the bug. So I giving a simplified source code of my project. 

      To catch the bug run my project on Visual Studio 2017, open FenParametres.cpp and FenPrincipale.cpp (these are the two useful files to see the bug, and more essentially FenParametres.cpp).

      Before going further, on the file FenParametres.cpp place a breakpoint at the line 96 : 

      if (etat == Qt::Unchecked)

       

      Our goal is to track when the signal stateChanged(int) is sent from the checkbox "ui.activerHistoriqueChkBox". The connection of this checkbox is at the line 12

      connect(ui.activerHistoriqueChkBox, SIGNAL(stateChanged(int)), this, SLOT(slotHistoriqueChkBox(int)));
      

      So the line 96 which is inside the slot slotHistoriqueChkBox(int) should stops everytime the signalChanged(int) is raised

      The interrupt breakpoint should stop when the user click on the checkbox or when ui.activerHistoriqueChkBox->setChecked(X); is done. And we have this

      ui.activerHistoriqueChkBox->setChecked(m_historiqueActive);

      at the line 42 and 63. Place breakpoints at those lines to see when the programs go there. 

      Now let's begin the test: Start a debug session

      At the menubar click on Fichier then Paramètres.

      This QDialog window will appear...
      Click on activer historique tu uncheck it 

      The debugger will stop at the line 96, because the state of the checkbox has been changed. Everything is normal, so let's continue the debug session...
      A Warning window will appear, click on "Annuler" (which means Cancel in French)

      Now the debugger will stop at the line 42, since this function "setActiverHistorique(bool on_off)" is called when you click on Cancel. The goal of this function is to re-check the checkbox since you've cancelled. Now the programm is about to execute this:

      ui.activerHistoriqueChkBox->setChecked(m_historiqueActive);
      

      and since the setChecked is called it should raise the signal stateChanged(int) and go again to the line 96 where there is our breakpoint. 

      However when we continue the debug sessions... we just see this window and nothing else happens....

      (please don't care about the other buttons)

      Now uncheck "Activer historique" checkbox by clicking on it:

      The program should raise the signal stateChanged(int) and stop at the breakpoint at the line 96... but again nothing happens...

      It's only now, if you recheck the checkbox then the programm will stop at the line 96. 

       

      Note that if you do theses changes, all will function normally:

      Stop debug session
      comment the line 12, and replace it by uncommenting the line 11

      connect(ui.activerHistoriqueChkBox, SIGNAL(toggled(bool)), this, SLOT(slotHistoriqueChkBox_v2(bool)));
      

      this line will replace the stateChanged(int) signal by toggled(bool), and replace the previous slot by this slotHistoriqueChkBox_v2(bool). slotHistoriqueChkBox_v2(bool) is quite identical to the previous slot except that the parameter in entry is a "bool" and not an "int". 

      Now place a breakpoint at the line 81 instead of 96. and start a debug session and redo the previous protocol, you will see this time all is working according to what it should be. 

      it is only the changeing of signal stateChanged(int) by toggled(bool) which made the bug disappear. 
      So I can conclude that the bug is very likely to come from the "stateChanged(int)" signal !

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            navis-raven Dragoon Gryffoon
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes