
Originally Posted by
d_stranz
Yes, point taken. I thought about that as well - a good number of the posts here are programming errors that are essentially equivalent to that example - allocate something on the stack, pass it to another QObject as a child or parent by dereferencing it, then it goes out of scope, and either it goes BOOM! or nothing happens as expected.
Just let's be clear again -- the code I posted is correct. For instance:
if(loginDialog.exec()) {
// ...
}
QMainWindow mw;
QDialog loginDialog(&mw);
if(loginDialog.exec()) {
// ...
}
To copy to clipboard, switch view to plain text mode
or more explicitly to avoid problems with broken compilers:
{
if(loginDialog.exec()) ...
}
QMainWindow mw;
{
QDialog loginDialog(&mw);
if(loginDialog.exec()) ...
}
To copy to clipboard, switch view to plain text mode
Then they haven't discovered boost::shared_ptr<> yet.
Unfortunately using smart pointers is not possible in every situation. I personally don't have any issues with memory management in C++ (even without using smart pointers).
I'm not sure that LGPL has all that much to do with it.
It's easy to explain. In the "pre-LGPL" era of Qt, you had to either pay for Qt (which was quite expensive, especially for people living in developing countries) or make your program open source (when using the GPL variant of the licence). Either way Qt was usually not the first choice for people wanting to write their first program but were rather used by companies and programming enthusiasts with a decent knowledge of C++. When LGPL came, Qt became accessible for virtually anyone in the world to use for pretty much anything. This caused a flood of would-be programmers from China and India as well as other Middle East countries. You can see that most of issues brought up here or on other forums related to Qt has nothing to do with Qt but rather with compilers, operating systems, low-level system API and of course C++.
Bookmarks