diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index e409d59a488..40e487be1f7 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -205,15 +205,17 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown() void CodepasterPlugin::postEditor() { + IEditor *editor = EditorManager::currentEditor(); + if (!editor) + return; + const IDocument *document = editor->document(); + const QString mimeType = document->mimeType(); QString data; - QString mimeType; - if (IEditor *editor = EditorManager::currentEditor()) { - if (ITextEditor *textEditor = qobject_cast(editor)) { - data = textEditor->selectedText(); - if (data.isEmpty()) - data = textEditor->textDocument()->plainText(); - mimeType = textEditor->document()->mimeType(); - } + if (const ITextEditor *textEditor = qobject_cast(editor)) + data = textEditor->selectedText(); + if (data.isEmpty()) { + if (const ITextEditorDocument *textDocument = qobject_cast(document)) + data = textDocument->plainText(); } post(data, mimeType); }