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

argc QApplication #1

Closed
Chocobozzz opened this issue Apr 7, 2015 · 6 comments
Closed

argc QApplication #1

Chocobozzz opened this issue Apr 7, 2015 · 6 comments

Comments

@Chocobozzz
Copy link

QApplication takes the argc adress &argc whereas you send the argc value to QApplication.

@itay-grudev
Copy link
Owner

&argc means alias of the argument provided. Therefore the way I wrote it is correct. Am I not right?

@Chocobozzz
Copy link
Author

I don't think so because I had segfault with the way you wrote, and after having added the & all is ok :p

From the doc "The data referred to by argc and argv must stay valid for the entire lifetime of the QApplication object". IMHO, the actual argc is send as a copy and so it is deleted when the constructor ends so argc is not valid for the entire lifetime of the application. It's the reason why we have to send the reference of argc, and not just a copy.

@itay-grudev
Copy link
Owner

So you propose that this:

SingleApplication::SingleApplication(int, char *[]);

Is changed to this:

SingleApplication::SingleApplication(int&, char *[]);

@Chocobozzz
Copy link
Author

Yes it is (as in QtSingleApplication).

itay-grudev added a commit that referenced this issue Apr 7, 2015
QApplication uses a reference of argc so it could modify it's value when
it substitutes known arguments for example.

Thanks to @Chocobozzz for reporting the issue.
#1
@Chocobozzz
Copy link
Author

Thanks to you to propose an elegant alternative to QtSingleApplication for Qt5 :)

@itay-grudev
Copy link
Owner

And Thank You for the fix!

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