I have a problem, I'm not sure how to solve it ..
We have a common pool of objects. When an object is requested, the pool returns QSharedPointerto the first available instance with the specified Deleter user. The deleter simply returns the object to the pool when the QSharedPointernumber of instance instances is 0. Everything works fine for simple objects. It also works great for successors QObjectwhen compiled in Qt 5.
However, if compiled in Qt 4.6, problems begin: when the same object is requested a second time, the application exits with an error:
"QSharedPointer: xxx pointer already has reference counting
I wrote a simple test:
QObject* obj = new QObject();
QSharedPointer<QObject> p(obj, deleter);
p.clear();
QSharedPointer<QObject> p2(obj, deleter);
And of course, this is not compiled in Qt 4.6. Again: works great in QT 5.x.
Qt, , 4.6 ref QObject, QObject QSharedPointer. , , , reset .
Qt5 ref, QObject , .
- Qt? - reset Qt, ? .