Commit b435f7bf authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Refactor text retrieval of the code paster plugin.

Try to obtain text via ITextEditorDocument.

Task-number: QTCREATORBUG-9669
Change-Id: Ie3816d84ea715691256f757fdd9a7b666fb6c27c
Reviewed-by: default avatarEike Ziller <>
parent 65c90924
......@@ -205,15 +205,17 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown()
void CodepasterPlugin::postEditor()
IEditor *editor = EditorManager::currentEditor();
if (!editor)
const IDocument *document = editor->document();
const QString mimeType = document->mimeType();
QString data;
QString mimeType;
if (IEditor *editor = EditorManager::currentEditor()) {
if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) {
data = textEditor->selectedText();
if (data.isEmpty())
data = textEditor->textDocument()->plainText();
mimeType = textEditor->document()->mimeType();
if (const ITextEditor *textEditor = qobject_cast<const ITextEditor *>(editor))
data = textEditor->selectedText();
if (data.isEmpty()) {
if (const ITextEditorDocument *textDocument = qobject_cast<const ITextEditorDocument *>(document))
data = textDocument->plainText();
post(data, mimeType);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment