Adds method to force the reloading of a document
AbandonedPublic

Authored by pedroarthurp on Apr 29 2017, 3:54 PM.

Details

Summary

Currently, KTextEditor::Document::documentReload() shows a dialog asking the user if he/she wants to reload a file from disk. However, there are use cases where reloading the file from disk is the norm and no user interaction is required. For example, an external script would make changes in the file and those changes should be immediately reloaded.

This patch then implements a mechanism through which KTextEditor clients could reload the file without asking user confirmation. The main motivation of this patch is to enable this no-confirmation-required file reloading to the external script facilities of kdevplataform.

Diff Detail

Repository
R39 KTextEditor
Lint
Lint Skipped
Unit
Unit Tests Skipped
pedroarthurp created this revision.Apr 29 2017, 3:54 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptApr 29 2017, 3:54 PM
Restricted Application added subscribers: Frameworks, kwrite-devel. · View Herald Transcript

D5673 shows a use-case for this feature.

I'm pretty sure this breaks ABI by adding a new virtual function... If an application was compiled against a previous version of KTextEditor and calls documentSave(), when run with a newer KTextEditor version (with this patch) it may end up calling the new documentReload(ReloadDocument). With garbage in the first argument.

I'm pretty sure this breaks ABI by adding a new virtual function... If an application was compiled against a previous version of KTextEditor and calls documentSave(), when run with a newer KTextEditor version (with this patch) it may end up calling the new documentReload(ReloadDocument). With garbage in the first argument.

Do you have any advice on how I would provide this functionality without breaking the ABI?

cullmann edited edge metadata.May 7 2017, 11:31 AM

You can add the function as non-virtual one.

Then call the right one of the d pointer, like we do for other new introduced view stuff:

KTextEditor::Cursor View::maxScrollPosition() const
{

return d->maxScrollPositionInternal();

}

Its bit ugly, as you have to do that manually but its BC.

cullmann requested changes to this revision.Aug 21 2017, 6:12 AM

Please go the non-virtual way, thanks. Or has somebody else a better idea (or dislikes the whole additional API function).

This revision now requires changes to proceed.Aug 21 2017, 6:12 AM
anthonyfieroni added a subscriber: anthonyfieroni.EditedAug 21 2017, 7:29 AM

Make a protected constructor

Document::Document(DocumentPrivate &dd) : d(&dd) {}

In KateDocument extend DocumentPrivate with KateDocumentPrivate, override documentReload and give it to base Document

KateDocument(...) : Document(*new KateDocumentPrivate)

Then make documentReload public non-virtual in Document with implementation

d->documentReload(...) => which will call KateDocumentPrivate override function

See e.g. document.cpp:

QVector<KTextEditor::Range> Document::searchText(const KTextEditor::Range &range, const QString &pattern, const SearchOptions options) const
{

return d->searchText(range, pattern, options);

}

how one can do that.

Restricted Application added a project: Kate. · View Herald TranscriptDec 11 2018, 8:19 PM
Restricted Application edited subscribers, added: kde-frameworks-devel; removed: Frameworks. · View Herald Transcript

Do we really need this? Or is this a reject?

pedroarthurp abandoned this revision.Mar 29 2019, 6:47 PM