Fix duplicated annotation context menus & entries on repeated border show

Authored by kossebau on Jul 22 2017, 6:46 PM.



Handler of annotationContextMenuAboutToShow was not disconnected,
thus accumulating connect calls and that way repeated addition
of on-the-fly-created actions "Copy Revision" & "History...".

Patch also fixes document-lifetime leakage of VcsAnnotationModel instances,
where used once were never deleted once the annotation border had been
removed again.

Test Plan

Before on multiple hide and show of the annotation border for the same
document the two actions mentioned above were duplicated by times of
shown border. With this patch they no longer are. No sideeffects seen.

Diff Detail

R33 KDevPlatform
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Jul 22 2017, 6:46 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJul 22 2017, 6:46 PM
brauch requested changes to this revision.Jul 31 2017, 6:07 PM

Hm, yes, it seems plausible to me that we need to do something like this ... I wonder though, wouldn't it be better if KTE took ownership of the model passed in, and deleted it when the border was hidden?


Why do you use string-based connect here...?
I think you can simply qobject_cast the view to AnnotationViewInterface* and use the modern function-pointer variant.

This revision now requires changes to proceed.Jul 31 2017, 6:07 PM
brauch accepted this revision.Aug 1 2017, 8:37 AM

never mind -- new style doesn't work in this case.
I think you should put a TODO KF6 and we should re-evaluate how ownership of this model works for that interface. Otherwise go for it I guess -- thanks!

This revision is now accepted and ready to land.Aug 1 2017, 8:37 AM
kossebau marked an inline comment as done.Aug 1 2017, 4:29 PM

Thanks for review.

Just found though that the approach in this patch for handling the model leakage ignores the case of multiple views on the same document (e.g. as used with projects where lots of classes are in a single long file) and where multiple views have annotation border visible and thus need the annotation model. Simply always deleting the model on hiding the border in one view will steal it from the other views then, not good.
So dropping the model leak deletion from this patch, needs more thought, and committing the rest, to fix at least the duplicated menu entries.

This revision was automatically updated to reflect the committed changes.