From b2c02478a0a9ac8d597333ba5030a1f1a175b2c2 Mon Sep 17 00:00:00 2001 From: ubbo Date: Mon, 5 Dec 2011 23:19:53 +0000 Subject: fix broken cut/copy/paste actions git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@657 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- textedit.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'textedit.cpp') diff --git a/textedit.cpp b/textedit.cpp index 5ad8976..e189754 100644 --- a/textedit.cpp +++ b/textedit.cpp @@ -211,6 +211,7 @@ void TextEdit::removeTab(int index) * If it returns false, the close event should be aborted. */ bool TextEdit::maybeSaveCurrentTab(bool askToSave) { + EditorPage *page = curPage(); QTextDocument *document = page->getTextPage()->document(); @@ -309,7 +310,11 @@ bool TextEdit::maybeSaveAnyTab() QTextEdit* TextEdit::curTextPage() { EditorPage *curTextPage = qobject_cast(tabWidget->currentWidget()); - return curTextPage->getTextPage(); + if(curTextPage != 0) { + return curTextPage->getTextPage(); + } else { + return 0; + } } @@ -445,7 +450,7 @@ QHash TextEdit::unsavedDocuments() { void TextEdit::cut() { - if (tabWidget->count() == 0) { + if (tabWidget->count() == 0 || curTextPage() == 0) { return; } @@ -454,7 +459,7 @@ void TextEdit::cut() void TextEdit::copy() { - if (tabWidget->count() == 0) { + if (tabWidget->count() == 0 || curTextPage() == 0) { return; } @@ -463,7 +468,7 @@ void TextEdit::copy() void TextEdit::paste() { - if (tabWidget->count() == 0) { + if (tabWidget->count() == 0 || curTextPage() == 0) { return; } @@ -472,7 +477,7 @@ void TextEdit::paste() void TextEdit::undo() { - if (tabWidget->count() == 0) { + if (tabWidget->count() == 0 || curTextPage() == 0) { return; } @@ -481,7 +486,7 @@ void TextEdit::undo() void TextEdit::redo() { - if (tabWidget->count() == 0) { + if (tabWidget->count() == 0 || curTextPage() == 0) { return; } @@ -490,7 +495,7 @@ void TextEdit::redo() void TextEdit::selectAll() { - if (tabWidget->count() == 0) { + if (tabWidget->count() == 0 || curTextPage() == 0) { return; } -- cgit v1.2.3