提问人:cj- 提问时间:11/11/2023 最后编辑:eyllanesccj- 更新时间:11/11/2023 访问量:20
错误访问返回 NSObject
Bad Access returning NSObject
问:
我遇到了一个相当常见的错误,即从 C++ 类方法返回由 Kotlin Multiplatform 创建的 NSObject 会导致EXC_BAD_ACCESS(由 Sentry Error Tracking 报告)。为什么会发生这种情况,可以做些什么来防止它?
以下是课程的相关部分:
AgraQML::MountPoint::MountPoint(SMLMountPoint* point) {
[point retain];
m_mountPoint = point;
}
AgraQML::MountPoint::~MountPoint() {
[m_mountPoint release];
}
SMLMountPoint* AgraQML::MountPoint::getMountPoint() const {
return m_mountPoint;
}
以下是 MountPoint 和 SMLMountPoint 的实例化方式:
SMLMountPoint *point = [[SMLMountPoint alloc] initWithRecord:mountPointRecord.toNSString()];
auto oldMountPoint = findChild<AgraQML::MountPoint*>();
AgraQML::MountPoint* mountPoint;
if (oldMountPoint == nullptr || oldMountPoint->path() != QString::fromNSString(point.path)) {
// Make a new MountPoint
mountPoint = new AgraQML::MountPoint(point);
mountPoint->setParent(this);
if (oldMountPoint != nullptr) // Remove the outdated MountPoint
oldMountPoint->deleteLater();
} else {
// Use the old MountPoint
mountPoint = oldMountPoint;
}
以下是发生的异常:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: SEGV_NOOP at 0x0000000000000010
Crashed Thread: 0
Application Specific Information:
__cxa_guard_release > _setInvalidatesViewsOnAppearanceChange: > application:didFinishLaunchingWithOptions: >
KERN_INVALID_ADDRESS at 0x10.
Thread 0 Crashed:
0 AgraGPS 0x2009acb74 AgraQML::MountPoint::getMountPoint (MountPoint.mm:16)
1 AgraGPS 0x20099877c AgraQML::NTRIP::restoreGetData (NTRIP.mm:61)
答: 暂无答案
评论
restoreGetData
getMountPoint
AgraQML::MountPoint