bug-fix: image links in reference format will cause crashes

This commit is contained in:
Le Tan 2017-09-23 14:56:53 +08:00
parent b04a44f82d
commit d20dc4a0b0
4 changed files with 19 additions and 4 deletions

View File

@ -70,6 +70,10 @@ Notice that the sequence number is irrelevant. Markdown will change the sequence
[Link Text](/url/of/the/link) [Link Text](/url/of/the/link)
``` ```
**Notes**:
- It is not recommended to use image links in reference format. VNote will not preview those images.
### Blockquotes ### Blockquotes
```md ```md
As VNote suggests: As VNote suggests:

View File

@ -71,6 +71,10 @@ __This text will be bold__
[Link Text](/url/of/the/link) [Link Text](/url/of/the/link)
``` ```
**注意**
- VNote不推荐使用参考式的图片链接。VNote不会预览这些图片。
### 块引用 ### 块引用
```md ```md
As VNote suggests: As VNote suggests:

View File

@ -189,8 +189,11 @@ QVector<ImageLink> VUtils::fetchImagesFromMarkdownFile(VFile *p_file,
const VElementRegion &reg = regions[i]; const VElementRegion &reg = regions[i];
QString linkText = text.mid(reg.m_startPos, reg.m_endPos - reg.m_startPos); QString linkText = text.mid(reg.m_startPos, reg.m_endPos - reg.m_startPos);
bool matched = regExp.exactMatch(linkText); bool matched = regExp.exactMatch(linkText);
Q_ASSERT(matched); if (!matched) {
Q_UNUSED(matched); // Image links with reference format will not match.
continue;
}
QString imageUrl = regExp.capturedTexts()[2].trimmed(); QString imageUrl = regExp.capturedTexts()[2].trimmed();
ImageLink link; ImageLink link;

View File

@ -303,6 +303,10 @@ void VImagePreviewer::fetchImageLinksFromRegions(QVector<ImageLinkInfo> &p_image
reg.m_endPos - reg.m_startPos)); reg.m_endPos - reg.m_startPos));
} }
if (info.m_linkUrl.isEmpty()) {
continue;
}
// Check if this image link has been previewed previously. // Check if this image link has been previewed previously.
info.m_previewImageID = isImageLinkPreviewed(info); info.m_previewImageID = isImageLinkPreviewed(info);