Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After receiving the signal, a dialog box pops up #200

Open
libaineu2004 opened this issue Oct 26, 2024 · 6 comments
Open

After receiving the signal, a dialog box pops up #200

libaineu2004 opened this issue Oct 26, 2024 · 6 comments

Comments

@libaineu2004
Copy link

libaineu2004 commented Oct 26, 2024

My source code implements: after receiving the instanceStarted signal, a prompt dialog box pops up.
But this causes a problem:
After clicking OK, the dialog box closes, but the main process also exits.
How can I solve this problem?

Windows 11/Qt5.15.2/VS2019 x64

int main(int argc, char *argv[])
{
    SingleApplication a(argc, argv);
    QObject::connect(&a, &SingleApplication::instanceStarted, [=]() {
        QMessageBox::information(0, QObject::tr("info"), QObject::tr("I am running"));
    });

    Form w;
    w.show();
    return a.exec();
}
@itay-grudev
Copy link
Owner

Can you verify the exit code of your application. I bet it's neither 0 nor 1. You will likely see that the exit code is >=128 which will indicate an issue like SIGSEGV, code 139.

@libaineu2004
Copy link
Author

libaineu2004 commented Oct 28, 2024

Can you verify the exit code of your application. I bet it's neither 0 nor 1. You will likely see that the exit code is >=128 which will indicate an issue like SIGSEGV, code 139.

I add std::cout print information. But there is no return value because the exe will crash.
Windows 11/Qt5.15.2/VS2019 x64

int main(int argc, char *argv[])
{
    SingleApplication a(argc, argv);
    QObject::connect(&a, &SingleApplication::instanceStarted, [=]() {
        QMessageBox::information(0, QObject::tr("info"), QObject::tr("I am running"));
    });

    Form w;
    w.show();
    int ret = a.exec();
    std::cout << ret << std::endl;
    return ret;
}

@itay-grudev
Copy link
Owner

itay-grudev commented Oct 28, 2024

I meant the exit code you get because of the crash. It's displayed either in QtCreator when you check the application output or if you run it manually through the terminal and after it crashes run: echo $?.

image

@libaineu2004
Copy link
Author

I meant the exit code you get because of the crash. It's displayed either in QtCreator when you check the application output or if you run it manually through the terminal and after it crashes run: echo $?.

image

Why does the exe crash? How to fix it?

@itay-grudev
Copy link
Owner

What's your exit code?

@libaineu2004
Copy link
Author

What's your exit code?

I am using Windows operating system, and I cannot capture this exit code when the exe crashes. Can you run my source code to see if it crashes as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants