Skip to content

Commit

Permalink
Complete fix for crash on pasting empty clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujan committed Oct 7, 2022
1 parent a659091 commit 39f7040
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
V1.3.3
---------
* Fixed crash on pasting when there is nothing to paste.
* Fixed crash on pasting with empty clipboard.
* Covered tab-indented here-docs in Bash syntax highlighting.
* Covered indented here-docs in Perl syntax highlighting.
* Silenced the compilation warnings with Qt ≥ 6.4.
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Latest version:

7 Oct 2022, V1.3.3
8 Oct 2022, V1.3.3

See "ChangeLog" for changes.
11 changes: 6 additions & 5 deletions featherpad/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,8 +1281,7 @@ void TextEdit::paste()
{
keepTxtCurHPos_ = false; // txtCurHPos_ isn't reset here because there may be nothing to paste

if (!canPaste()) return;
pasting_ = true; // see insertFromMimeData()
pasting_ = true; // see insertFromMimeData()
QPlainTextEdit::paste();
pasting_ = false;
}
Expand Down Expand Up @@ -1317,12 +1316,14 @@ QMimeData* TextEdit::createMimeDataFromSelection() const
// We also want to control whether the pasted URLs should be opened.
bool TextEdit::canInsertFromMimeData (const QMimeData* source) const
{
return (source && source->hasUrls()) || QPlainTextEdit::canInsertFromMimeData (source);
return source != nullptr
&& (source->hasUrls() || QPlainTextEdit::canInsertFromMimeData (source));
}
void TextEdit::insertFromMimeData (const QMimeData* source)
{
keepTxtCurHPos_ = false;
if (source && source->hasUrls())
if (source == nullptr) return;
if (source->hasUrls())
{
const QList<QUrl> urlList = source->urls();
bool multiple (urlList.count() > 1);
Expand Down Expand Up @@ -1360,7 +1361,7 @@ void TextEdit::insertFromMimeData (const QMimeData* source)
}
}
}
else
else if (source->hasText())
QPlainTextEdit::insertFromMimeData (source);
}
/*************************/
Expand Down

0 comments on commit 39f7040

Please sign in to comment.