Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file
Forum Updated to NodeBB v4.3 + New Features

dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 429 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    micha_eleric
    wrote on last edited by
    #1

    What appears random, because it appears to be calling

    emitMessageBoxRed("pass 1 can not = '' or '0' ");
    

    is not actually leaving

    void BtnDistTestEquals()
    

    so, error is in

    void BtnDistTestEquals()
        {
            emitPrint("================ BtnDistTestEquals ================");
            int t46 = m_ui->textEdit_46->toPlainText().toInt();
            int t47 = m_ui->textEdit_47->toPlainText().toInt();
            int t48 = m_ui->textEdit_48->toPlainText().toInt();
            int pass = m_threadcontroller->GetPass();
            char axis = m_threadcontroller->GetAxis();
            emitPrint("BtnDistTestEquals  axis = " + axis);
    
            if( (t46 == 0) && (pass == 1) )
            {
                Print("BtnDistTestEquals  ( (t46 == 0) && (pass == 1) )");
                emitMessageBoxRed("pass 1 can not = '' or '0' ");
            }
            else if( (t47 == 0) && (pass == 2) )
            {
                emitMessageBoxRed("pass 2 can not = '' or '0' ");
            }
            else if( (t48 == 0) && (pass == 3) )
            {
                emitMessageBoxRed("pass 3 can not = '' or '0' ");
            }
            else
            {
                Print("BtnDistTestEquals  else");
                function();
            }
        }
        // ------------------------- END -------------------------
    

    because
    1 can not = '' or '0'
    or
    2 can not = '' or '0'
    or
    3 can not = '' or '0'
    was printed, i assumed

    emitMessageBoxRed()
    

    was called, which has thee print statements, but only second Print() appeared to be called.
    add an extra Print() into first if(), keep fragment of string in other two if()'s from being printed.

    void Print(std::string s)
        {
            m_file << std::flush << s << '\n' << std::flush;
            std::cout << std::flush << s << '\n' << std::flush;
        }
    

    how fragment of string printed to konsole and file, without std::cout nor std::ofstream being called?
    how can anything in if() statement, get printed, when if() statement is not entered?

    debug shows that if() statement is not entered, and string fragment is printed at if() statement check.

    i thought it was an error with std::cout and std::ofstream, not printing everything all the time, but they are not called, at least according to debugger.

    jsulmJ 1 Reply Last reply
    0
    • M micha_eleric

      What appears random, because it appears to be calling

      emitMessageBoxRed("pass 1 can not = '' or '0' ");
      

      is not actually leaving

      void BtnDistTestEquals()
      

      so, error is in

      void BtnDistTestEquals()
          {
              emitPrint("================ BtnDistTestEquals ================");
              int t46 = m_ui->textEdit_46->toPlainText().toInt();
              int t47 = m_ui->textEdit_47->toPlainText().toInt();
              int t48 = m_ui->textEdit_48->toPlainText().toInt();
              int pass = m_threadcontroller->GetPass();
              char axis = m_threadcontroller->GetAxis();
              emitPrint("BtnDistTestEquals  axis = " + axis);
      
              if( (t46 == 0) && (pass == 1) )
              {
                  Print("BtnDistTestEquals  ( (t46 == 0) && (pass == 1) )");
                  emitMessageBoxRed("pass 1 can not = '' or '0' ");
              }
              else if( (t47 == 0) && (pass == 2) )
              {
                  emitMessageBoxRed("pass 2 can not = '' or '0' ");
              }
              else if( (t48 == 0) && (pass == 3) )
              {
                  emitMessageBoxRed("pass 3 can not = '' or '0' ");
              }
              else
              {
                  Print("BtnDistTestEquals  else");
                  function();
              }
          }
          // ------------------------- END -------------------------
      

      because
      1 can not = '' or '0'
      or
      2 can not = '' or '0'
      or
      3 can not = '' or '0'
      was printed, i assumed

      emitMessageBoxRed()
      

      was called, which has thee print statements, but only second Print() appeared to be called.
      add an extra Print() into first if(), keep fragment of string in other two if()'s from being printed.

      void Print(std::string s)
          {
              m_file << std::flush << s << '\n' << std::flush;
              std::cout << std::flush << s << '\n' << std::flush;
          }
      

      how fragment of string printed to konsole and file, without std::cout nor std::ofstream being called?
      how can anything in if() statement, get printed, when if() statement is not entered?

      debug shows that if() statement is not entered, and string fragment is printed at if() statement check.

      i thought it was an error with std::cout and std::ofstream, not printing everything all the time, but they are not called, at least according to debugger.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @micha_eleric said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

      how can anything in if() statement, get printed, when if() statement is not entered?

      Well, if that's the only place where it is printed then the if block was entered. Did you debug your code to see what is happening?
      Also, it is hard to understand what you're writing.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      1
      • jsulmJ jsulm

        @micha_eleric said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

        how can anything in if() statement, get printed, when if() statement is not entered?

        Well, if that's the only place where it is printed then the if block was entered. Did you debug your code to see what is happening?
        Also, it is hard to understand what you're writing.

        M Offline
        M Offline
        micha_eleric
        wrote on last edited by
        #3

        @jsulm said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

        @micha_eleric said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

        how can anything in if() statement, get printed, when if() statement is not entered?

        Well, if that's the only place where it is printed then the if block was entered. Did you debug your code to see what is happening?
        Also, it is hard to understand what you're writing.

        yes, i ran debug, it never entered the if() statement.
        if

        Print("BtnDistTestEquals  ( (t46 == 0) && (pass == 1) )");
        

        is in the first if() statement, then regardless of value of

        pass
        

        then

        ( (t46 == 0) && (pass == 1) )
        

        is printed.

        if

        Print("BtnDistTestEquals  ( (t46 == 0) && (pass == 1) )");
        

        is not in first if() statement, then

        1 can not = '' or '0' 
        

        is printed when pass = 1

        2 can not = '' or '0' 
        

        is printed when pass = 2

        3 can not = '' or '0' 
        

        is printed when pass = 3

        emitMessageBoxRed
        

        is never called, yet part of string to be sent to

        emitMessageBoxRed
        

        is printed, not all of string

        put a break on line

        emitMessageBoxRed
        

        is called, then debug never stops

        jsulmJ 1 Reply Last reply
        0
        • M micha_eleric

          @jsulm said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

          @micha_eleric said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

          how can anything in if() statement, get printed, when if() statement is not entered?

          Well, if that's the only place where it is printed then the if block was entered. Did you debug your code to see what is happening?
          Also, it is hard to understand what you're writing.

          yes, i ran debug, it never entered the if() statement.
          if

          Print("BtnDistTestEquals  ( (t46 == 0) && (pass == 1) )");
          

          is in the first if() statement, then regardless of value of

          pass
          

          then

          ( (t46 == 0) && (pass == 1) )
          

          is printed.

          if

          Print("BtnDistTestEquals  ( (t46 == 0) && (pass == 1) )");
          

          is not in first if() statement, then

          1 can not = '' or '0' 
          

          is printed when pass = 1

          2 can not = '' or '0' 
          

          is printed when pass = 2

          3 can not = '' or '0' 
          

          is printed when pass = 3

          emitMessageBoxRed
          

          is never called, yet part of string to be sent to

          emitMessageBoxRed
          

          is printed, not all of string

          put a break on line

          emitMessageBoxRed
          

          is called, then debug never stops

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @micha_eleric said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

          i ran debug, it never entered the if() statement.

          Then please check your conditions. If your if statements are not entered then your t46 and pass don't have the values you think they have. You can easily check their values using debugger or printing them...

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          4
          • jsulmJ jsulm

            @micha_eleric said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

            i ran debug, it never entered the if() statement.

            Then please check your conditions. If your if statements are not entered then your t46 and pass don't have the values you think they have. You can easily check their values using debugger or printing them...

            M Offline
            M Offline
            micha_eleric
            wrote on last edited by
            #5

            @jsulm said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

            @micha_eleric said in dont know what to call error/bug. part of string printed to file and konsole, without calling cout or std::ofstream m_file:

            i ran debug, it never entered the if() statement.

            Then please check your conditions. If your if statements are not entered then your t46 and pass don't have the values you think they have. You can easily check their values using debugger or printing them...

            that is the issue and question. the condition to enter the three if() statements are not meet, yet part of string, not the whole string is printed, AND

            emitMessageBoxRed
            

            does more than just print to konsole and file.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved