Text not written to konsole and file

Joined
Jan 11, 2023
Messages
9
Reaction score
0
Code:
        m_file << e.toStdString() << '\n' << std::flush;
        std::cout << e.toStdString() << '\n' << std::flush;

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

may or may not print same text
may or may not print part in one and whole in other
may or may not print in one, but not in other
 
Joined
Dec 21, 2022
Messages
28
Reaction score
4
Without more context nobody can give you an answer.
What is m_file? What is e?
When does it happen? Which OS?
Complete program for can reproduce it?
 
Joined
Jan 11, 2023
Messages
9
Reaction score
0
m_file.open("OutputFile.txt");
"When does it happen?" randomly, sometimes in same function
"What is e?" QString e
"Which OS?" linux
"Complete program for can reproduce it?" a few 1000's lines

i found a a missing Print(std::string s), when i was trying to find a partial output string, then noticed a string was not displayed in gui.
it seems to be an std error and not a qstring error, since it starts with std::string not displaying in neither konsole nor file
 
Joined
Jan 11, 2023
Messages
9
Reaction score
0
ok, this makes no sense.
if i use:
HTML:
if( (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
{
    function();
}

then, first Print("something"); in emitMessageBoxRed, is not called, but 1 can not = '' or '0', 2 can not = '' or '0', or 3 can not = '' or '0', is printed, depending on value of pass, and rest of emitMessageBoxRed is not called, AND function(); of else is called

if
i use:
HTML:
if( (t46 == 0) && (pass == 1) )
{
     Print(" ( (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
{
    function();
}

then ( (t46 == 0) && (pass == 1) ), none of emitMessageBoxRed(), regardless of value of pass, is called, AND function(); of else is called
 
Last edited:
Joined
Jan 11, 2023
Messages
9
Reaction score
0
when running debug, when code gets to
Code:
if( (t46 == 0) && (pass == 1) )

( (t46 == 0) && (pass == 1) ), is printed
code never enters if condition
 
Joined
Jan 11, 2023
Messages
9
Reaction score
0
What appears random, because it appears to be calling
Code:
emitMessageBoxRed("pass 1 can not = '' or '0' ");
is not actually leaving
Code:
void BtnDistTestEquals()

so, error is in
Code:
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
Code:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top