Re: Search function in xconfig is partially broken after recent changes

From: Mauro Carvalho Chehab
Date: Sun Jun 28 2020 - 07:56:39 EST


Em Sun, 28 Jun 2020 14:20:41 +0300
Maxim Levitsky <mlevitsk@xxxxxxxxxx> escreveu:

> > But this is not happening. Perhaps this also broke with the Qt5
> > conversion?
> >
> > I suspect it should, instead, use a different signal to handle it.
> >
> > See, with the enclosed patch, clicking on a link will now show:
> >
> > Clicked on URL QUrl("s0x21c3f10")
> > QTextBrowser: No document for s0x21c3f10
> >
> > Which helps to explain what's happening here.
> >
> > See, when debug is turned on, it will create hyperlinks like:
> >
> > head += QString().sprintf("<a href=\"s%p\">", sym);
> >
> > It seems that the code needs something like:
> >
> > connect (helpText, SIGNAL (anchorClicked (const QUrl &)),
> > helpText, SLOT (clicked (const QUrl &)) );
> >
> > and a handler for this signal that would translate "s%p"
> > back into sym, using such value to update the menus.
> >
> > Do you know if this used to work after Kernel 3.14?
>
> I don't know yet, but I can test it.
>
> I didn't do much kernel developement for lot of time, so I only vaguely
> remember that once upon a time it did work. I don't use this feature much,
> so it might as well be broken back when conversion to Qt5 happened.
> Also worth noting that I probably used Qt4 untill recently when I updated
> to fedora 31, which looks like dropped Qt4 developement packages.
>
> I used to know a thing or two about Qt, long long ago, so on next weekend or so,
> I can also take a look at this.

Yeah, I suspect you probably tried it before the Qt5 conversion
patches then.

The enclosed patch is one step further fixing this bug. It still
needs to implement the part of the code which starts using the
selected menu or item.

The first hunk won't apply cleanly, because I added a patch
before it, in order to sort out the include mess, but solving
the conflict is trivial (just add an include for QDebug).

Thanks,
Mauro

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 631e19659504..b989b6543d7a 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -7,6 +7,7 @@
#include <QAction>
#include <QApplication>
#include <QCloseEvent>
+#include <QDebug>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QLabel>
@@ -1012,7 +1013,7 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
: Parent(parent), sym(0), _menu(0)
{
setObjectName(name);
-
+ setOpenLinks(false);

if (!objectName().isEmpty()) {
configSettings->beginGroup(objectName());
@@ -1224,6 +1225,36 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
*text += str2;
}

+void ConfigInfoView::clicked(const QUrl &url)
+{
+ QByteArray str = url.toEncoded();
+ const std::size_t count = str.size();
+ char *hex = new char[count];
+ unsigned long p;
+ struct symbol *sym;
+ struct menu *menu;
+
+ if (count < 1)
+ return;
+
+ memcpy(hex, str.constData(), count);
+ p = (int)strtol(hex + 1, NULL, 16);
+
+ if (!p)
+ return;
+
+ qInfo() << "Clicked on URL" << url;
+
+ if (hex[0] == 's') {
+ sym = (struct symbol *)p;
+
+ qInfo() << "symbol name:" << sym->name;
+ } else {
+ menu = (struct menu *)p;
+ qInfo() << "menu:" << qgettext(menu_get_prompt(menu));
+ }
+}
+
QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
{
QMenu* popup = Parent::createStandardContextMenu(pos);
@@ -1497,6 +1528,9 @@ ConfigMainWindow::ConfigMainWindow(void)
helpMenu->addAction(showIntroAction);
helpMenu->addAction(showAboutAction);

+ connect (helpText, SIGNAL (anchorClicked (const QUrl &)),
+ helpText, SLOT (clicked (const QUrl &)) );
+
connect(configList, SIGNAL(menuChanged(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(configList, SIGNAL(menuSelected(struct menu *)),
@@ -1601,6 +1635,9 @@ void ConfigMainWindow::searchConfig(void)

void ConfigMainWindow::changeItens(struct menu *menu)
{
+ if (menu->flags & MENU_ROOT)
+ qInfo() << "Wrong type when changing item";
+
configList->setRootMenu(menu);

if (configList->rootEntry->parent == &rootmenu)
@@ -1611,6 +1648,9 @@ void ConfigMainWindow::changeItens(struct menu *menu)

void ConfigMainWindow::changeMenu(struct menu *menu)
{
+ if (!(menu->flags & MENU_ROOT))
+ qInfo() << "Wrong type when changing menu";
+
menuList->setRootMenu(menu);

if (menuList->rootEntry->parent == &rootmenu)
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index d913a02967ae..a193137f2314 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -250,6 +250,7 @@ public slots:
void setInfo(struct menu *menu);
void saveSettings(void);
void setShowDebug(bool);
+ void clicked (const QUrl &url);

signals:
void showDebugChanged(bool);