Skip to content

Commit 0282c43

Browse files
nhojbwjakob
authored andcommitted
Adding check for null Screen which was causing a crash in our project. (#245)
1 parent e70b5a6 commit 0282c43

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/textbox.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ bool TextBox::checkFormat(const std::string &input, const std::string &format) {
513513
bool TextBox::copySelection() {
514514
if (mSelectionPos > -1) {
515515
Screen *sc = dynamic_cast<Screen *>(this->window()->parent());
516+
if (!sc)
517+
return false;
516518

517519
int begin = mCursorPos;
518520
int end = mSelectionPos;
@@ -530,6 +532,8 @@ bool TextBox::copySelection() {
530532

531533
void TextBox::pasteFromClipboard() {
532534
Screen *sc = dynamic_cast<Screen *>(this->window()->parent());
535+
if (!sc)
536+
return;
533537
const char* cbstr = glfwGetClipboardString(sc->glfwWindow());
534538
if (cbstr)
535539
mValueTemp.insert(mCursorPos, std::string(cbstr));

0 commit comments

Comments
 (0)