* We have two cases to consider here: * (1) our thread: * - emit objectDestroyed() right away * (2) other thread: * - post information to our thread, emit objectDestroyed() there * * pre-conditions: arbitrary thread, lock may or may not be held already */
| 652 | * pre-conditions: arbitrary thread, lock may or may not be held already |
| 653 | */ |
| 654 | void Probe::objectRemoved(QObject *obj) |
| 655 | { |
| 656 | QMutexLocker lock(s_lock()); |
| 657 | |
| 658 | if (!isInitialized()) { |
| 659 | IF_DEBUG(cout |
| 660 | << "objectRemoved Before: " |
| 661 | << hex << obj |
| 662 | << " have statics: " << s_listener() << endl;) |
| 663 | |
| 664 | if (!s_listener()) |
| 665 | return; |
| 666 | |
| 667 | QVector<QObject *> &addedBefore = s_listener()->addedBeforeProbeInstance; |
| 668 | for (auto it = addedBefore.begin(); it != addedBefore.end();) { |
| 669 | if (*it == obj) |
| 670 | it = addedBefore.erase(it); |
| 671 | else |
| 672 | ++it; |
| 673 | } |
| 674 | return; |
| 675 | } |
| 676 | |
| 677 | IF_DEBUG(cout << "object removed:" << hex << obj << " " << obj->parent() << endl;) |
| 678 | |
| 679 | bool success = instance()->m_validObjects.remove(obj); |
| 680 | if (!success) { |
| 681 | // object was not tracked by the probe, probably a gammaray object |
| 682 | EXPENSIVE_ASSERT(!instance()->isObjectCreationQueued(obj)); |
| 683 | return; |
| 684 | } |
| 685 | |
| 686 | instance()->purgeChangesForObject(obj); |
| 687 | EXPENSIVE_ASSERT(!instance()->isObjectCreationQueued(obj)); |
| 688 | |
| 689 | if (instance()->thread() == QThread::currentThread()) |
| 690 | emit instance()->objectDestroyed(obj); |
| 691 | else |
| 692 | instance()->queueDestroyedObject(obj); |
| 693 | } |
| 694 | |
| 695 | void Probe::handleObjectDestroyed(QObject *obj) |
| 696 | { |
nothing calls this directly
no test coverage detected