Why lazy initialization of Text Views breaks the context menu
Andreas Pakulat
apaku at gmx.de
Sat Dec 15 14:29:08 UTC 2012
Hi,
I've been debugging the problem of why no context menu is shown on
newly opened files or the one initially visible when delaying the kate
view intialization using a queued-invocation. The reason is that
apparently in these cases the xmlgui merging does not happen. In
particular kate's view looks for a container in the top-most
parentClient with the object name "ktexteditor_popup", see
https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/master/entry/part/view/kateview.cpp#L2680.
When the initialization of the KateView is not done in the consturctor
of TextEditorWidget this menu is not available, instead one only sees
stuff from kdevelop's xmlgui file like:
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x97011c8, name = "session") KMenu "session"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x981bf00, name = "project") KMenu "project"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x97168d0, name = "run") KMenu "run"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x970d9a8, name = "navigation") KMenu "navigation"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x970e890, name = "file") KMenu "file"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x98131e0, name = "edit") KMenu "edit"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x9820cb0, name = "editor") KMenu "editor"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x98148f8, name = "code") KMenu "code"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x9820308, name = "window") KMenu "window"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x9818e30, name = "settings") KMenu "settings"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x981ab58, name = "help") KMenu "help"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x9822750, name = "rb_popup") KMenu "rb_popup"
kdevelop(21681)/Kate KateView::contextMenu: check container:
KMenu(0x9bb0388, name = "cvs_popup") KMenu "cvs_popup"
In addition the factory for the kateview itself is null and hence has
no containers to retrieve. In the other case, i.e. calling
TextEditorWidget::initialize directly from the constructor the result
is that there are also some kate-related things in the xmlgui file:
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9b16e90, name = "session") KMenu "session"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9a0c7c0, name = "project") KMenu "project"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9a0c9a0, name = "run") KMenu "run"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9a039b0, name = "navigation") KMenu "navigation"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9a04888, name = "file") KMenu "file"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9b0ab40, name = "edit") KMenu "edit"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0xa5b7ad0, name = "edit_advanced") KMenu "edit_advanced"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x99faca8, name = "editor") KMenu "editor"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0xb0c0d08, name = "view") KMenu "view"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0xb0c5470, name = "codefolding") KMenu "codefolding"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0xb0c1300, name = "tools") KMenu "tools"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0xb0cdf30, name = "wordcompletion") KMenu "wordcompletion"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9b0df90, name = "code") KMenu "code"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9b15568, name = "window") KMenu "window"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9b0e9a8, name = "settings") KMenu "settings"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9b0a840, name = "help") KMenu "help"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0xb0d24d8, name = "tools") KMenu "tools"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9b186c8, name = "rb_popup") KMenu "rb_popup"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0x9eb8d58, name = "cvs_popup") KMenu "cvs_popup"
kdevelop(24653)/Kate KateView::contextMenu: check view container:
KMenu(0xb0d1130, name = "ktexteditor_popup") KMenu "ktexteditor_popup"
and more importantly the kateview's own xmlgui factory is not null and
is the one being used.
So I guess in addition to an KXMLGUIClient::insertChildClient one
needs to do something else to properly hookup an xmlgui client into
the framework and usually this is done by something that comes after
creating the text editor widget. Unfortunately I don't know either
xmlgui or our own mainwindow/ideal/etc. code enough to even guess what
that might be. Anybody has an idea what might be missing? It must be
something that is also triggered when switching documents since thats
a workaround to get the context menu to appear in the originally
broken view as well.
Andreas
More information about the KDevelop-devel
mailing list