c++ - CTLineGetStringIndexForPosition 因 bad_alloc 而崩溃
问题描述
我试图在这样的一行中获取文本的位置:
CFIndex Idx = CTLineGetStringIndexForPosition(line, pos);
但是我因以下堆栈跟踪而崩溃。为什么会发生崩溃?
- libc++.1.dylib std::__throw_bad_alloc()
- CoreText std::__1::__split_buffer<TLine::CaretInfo, std::__1::allocator<TLine::CaretInfo>&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator<TLine::CaretInfo>&)
- CoreText void std::__1::vector<TLine::CaretInfo, std::__1::allocator<TLine::CaretInfo> >::__emplace_back_slow_path<TLine::CaretInfo>(TLine::CaretInfo&&)
- CoreText TLine::EnumerateCaretOffsets(std::__1::function<void (double, long, bool, bool*)>) const
- CoreText TLine::PositionToCharIndex(CGPoint) const
- CTLineGetStringIndexForPosition(line, pos);
解决方案
推荐阅读
- python - 如何向执行命令的用户发送 DM 并发送到频道
- python - ValueError: `.fit()` 的输入应该有 4 级。在 CNN 中有形状的数组吗?
- python - 使用 Python Selenium 循环遍历 CSV 文件中的 URL 链接
- usb - 在追溯中区分具有相同产品/供应商 ID 的两个 USB 设备的方法
- javascript - 如何动态地使接口键成为必需(或使其成为可选)
- python - Selenium 中的 Instagram XPath 不起作用?(Python)
- javascript - 如何检查输入是否只包含0和1?
- elasticsearch - 编写一个查询而不是四个查询
- grails - Grails 2.4.4 与 Java 8 的兼容性
- python - 如何在临时目录中写入和读取 txt 文件?