kconfig: qconf: make debug links work again
diff mbox series

Message ID ff9d1c3369b96c1d14b1e898e3d5f64ad945b604.1593346883.git.mchehab+huawei@kernel.org
State New
Headers show
Series
  • kconfig: qconf: make debug links work again
Related show

Commit Message

Mauro Carvalho Chehab June 28, 2020, 12:21 p.m. UTC
The Qt5 conversion broke support for debug info links.

Restore the behaviour added by changeset
ab45d190fd4a ("kconfig: create links in info window").

Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 scripts/kconfig/qconf.cc | 35 ++++++++++++++++++++++++++++++++++-
 scripts/kconfig/qconf.h  |  1 +
 2 files changed, 35 insertions(+), 1 deletion(-)

Comments

Maxim Levitsky June 28, 2020, 12:25 p.m. UTC | #1
On Sun, 2020-06-28 at 14:21 +0200, Mauro Carvalho Chehab wrote:
> The Qt5 conversion broke support for debug info links.
> 
> Restore the behaviour added by changeset
> ab45d190fd4a ("kconfig: create links in info window").
> 
> Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  scripts/kconfig/qconf.cc | 35 ++++++++++++++++++++++++++++++++++-
>  scripts/kconfig/qconf.h  |  1 +
>  2 files changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> index 631e19659504..03cadf27a376 100644
> --- a/scripts/kconfig/qconf.cc
> +++ b/scripts/kconfig/qconf.cc
> @@ -1012,7 +1012,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 +1224,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;
> +
> +	if (count < 1)
> +		return;
> +
> +	memcpy(hex, str.constData(), count);
> +	p = (int)strtol(hex + 1, NULL, 16);
> +
> +	if (!p)
> +		return;
> +
> +	if (hex[0] == 's') {
> +		struct symbol *s = (struct symbol *)p;
> +
> +		sym = s;
> +		symbolInfo();
> +	} else {
> +		struct menu *m = (struct menu *)p;
> +
> +		_menu = m;
> +		menuInfo();
> +	}
> +	emit showDebugChanged(true);
> +}
> +
>  QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
>  {
>  	QMenu* popup = Parent::createStandardContextMenu(pos);
> @@ -1497,6 +1527,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 *)),
> 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);

Just tested it and it works well. Thank you very much!

Best regards,
	Maxim Levitsky
Masahiro Yamada June 28, 2020, 2:41 p.m. UTC | #2
On Sun, Jun 28, 2020 at 9:21 PM Mauro Carvalho Chehab
<mchehab+huawei@kernel.org> wrote:
>
> The Qt5 conversion broke support for debug info links.
>
> Restore the behaviour added by changeset
> ab45d190fd4a ("kconfig: create links in info window").
>
> Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


I tested this patch, but this caused
segmentation fault.


I enabled 'Show Debug Info',
and then clicked
dep: <symbol name>.

Then, xconfig crashed.

(without this patch, it did not cause
segfault at least)

Did you see this?











> ---
>  scripts/kconfig/qconf.cc | 35 ++++++++++++++++++++++++++++++++++-
>  scripts/kconfig/qconf.h  |  1 +
>  2 files changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> index 631e19659504..03cadf27a376 100644
> --- a/scripts/kconfig/qconf.cc
> +++ b/scripts/kconfig/qconf.cc
> @@ -1012,7 +1012,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 +1224,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;
> +
> +       if (count < 1)
> +               return;
> +
> +       memcpy(hex, str.constData(), count);
> +       p = (int)strtol(hex + 1, NULL, 16);
> +
> +       if (!p)
> +               return;
> +
> +       if (hex[0] == 's') {
> +               struct symbol *s = (struct symbol *)p;
> +
> +               sym = s;
> +               symbolInfo();
> +       } else {
> +               struct menu *m = (struct menu *)p;
> +
> +               _menu = m;
> +               menuInfo();
> +       }
> +       emit showDebugChanged(true);
> +}
> +
>  QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
>  {
>         QMenu* popup = Parent::createStandardContextMenu(pos);
> @@ -1497,6 +1527,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 *)),
> 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);
> --
> 2.26.2
>
Maxim Levitsky June 28, 2020, 2:48 p.m. UTC | #3
On Sun, 2020-06-28 at 23:41 +0900, Masahiro Yamada wrote:
> On Sun, Jun 28, 2020 at 9:21 PM Mauro Carvalho Chehab
> <mchehab+huawei@kernel.org> wrote:
> > The Qt5 conversion broke support for debug info links.
> > 
> > Restore the behaviour added by changeset
> > ab45d190fd4a ("kconfig: create links in info window").
> > 
> > Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> 
> I tested this patch, but this caused
> segmentation fault.
> 
> 
> I enabled 'Show Debug Info',
> and then clicked
> dep: <symbol name>.
> 
> Then, xconfig crashed.
> 
> (without this patch, it did not cause
> segfault at least)
> 
> Did you see this?

Works for me - tested this again 
(I have both patches applied on top on mainline master branch).
Maybe you have Qt4?

One thing that I forgot to report is that when clicking on the symbol,
only config descripion updates and not config/menu windows.
It might even be always like that, I don't remember, but it would be nice if 
these were updated too.

Best regards,
	Maxim Levitsky

> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> > ---
> >  scripts/kconfig/qconf.cc | 35 ++++++++++++++++++++++++++++++++++-
> >  scripts/kconfig/qconf.h  |  1 +
> >  2 files changed, 35 insertions(+), 1 deletion(-)
> > 
> > diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> > index 631e19659504..03cadf27a376 100644
> > --- a/scripts/kconfig/qconf.cc
> > +++ b/scripts/kconfig/qconf.cc
> > @@ -1012,7 +1012,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 +1224,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;
> > +
> > +       if (count < 1)
> > +               return;
> > +
> > +       memcpy(hex, str.constData(), count);
> > +       p = (int)strtol(hex + 1, NULL, 16);
> > +
> > +       if (!p)
> > +               return;
> > +
> > +       if (hex[0] == 's') {
> > +               struct symbol *s = (struct symbol *)p;
> > +
> > +               sym = s;
> > +               symbolInfo();
> > +       } else {
> > +               struct menu *m = (struct menu *)p;
> > +
> > +               _menu = m;
> > +               menuInfo();
> > +       }
> > +       emit showDebugChanged(true);
> > +}
> > +
> >  QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
> >  {
> >         QMenu* popup = Parent::createStandardContextMenu(pos);
> > @@ -1497,6 +1527,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 *)),
> > 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);
> > --
> > 2.26.2
> > 
> 
>
Masahiro Yamada June 28, 2020, 2:58 p.m. UTC | #4
On Sun, Jun 28, 2020 at 11:48 PM Maxim Levitsky <mlevitsk@redhat.com> wrote:
>
> On Sun, 2020-06-28 at 23:41 +0900, Masahiro Yamada wrote:
> > On Sun, Jun 28, 2020 at 9:21 PM Mauro Carvalho Chehab
> > <mchehab+huawei@kernel.org> wrote:
> > > The Qt5 conversion broke support for debug info links.
> > >
> > > Restore the behaviour added by changeset
> > > ab45d190fd4a ("kconfig: create links in info window").
> > >
> > > Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> >
> > I tested this patch, but this caused
> > segmentation fault.
> >
> >
> > I enabled 'Show Debug Info',
> > and then clicked
> > dep: <symbol name>.
> >
> > Then, xconfig crashed.
> >
> > (without this patch, it did not cause
> > segfault at least)
> >
> > Did you see this?
>
> Works for me - tested this again
> (I have both patches applied on top on mainline master branch).
> Maybe you have Qt4?


I do not think so.

I checked scripts/kconfig/.qconf.cmd

qconf was linked with Qt5.


$ cat scripts/kconfig/.qconf.cmd
cmd_scripts/kconfig/qconf := g++   -o scripts/kconfig/qconf
scripts/kconfig/images.o scripts/kconfig/confdata.o
scripts/kconfig/expr.o scripts/kconfig/lexer.lex.o
scripts/kconfig/parser.tab.o scripts/kconfig/preprocess.o
scripts/kconfig/symbol.o scripts/kconfig/util.o
scripts/kconfig/qconf.o   -lQt5Widgets -lQt5Gui -lQt5Core


BTW, my machine runs ubuntu 20.04




>
> One thing that I forgot to report is that when clicking on the symbol,
> only config descripion updates and not config/menu windows.
> It might even be always like that, I don't remember, but it would be nice if
> these were updated too.
>
> Best regards,
>         Maxim Levitsky
>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > ---
> > >  scripts/kconfig/qconf.cc | 35 ++++++++++++++++++++++++++++++++++-
> > >  scripts/kconfig/qconf.h  |  1 +
> > >  2 files changed, 35 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> > > index 631e19659504..03cadf27a376 100644
> > > --- a/scripts/kconfig/qconf.cc
> > > +++ b/scripts/kconfig/qconf.cc
> > > @@ -1012,7 +1012,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 +1224,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;
> > > +
> > > +       if (count < 1)
> > > +               return;
> > > +
> > > +       memcpy(hex, str.constData(), count);
> > > +       p = (int)strtol(hex + 1, NULL, 16);
> > > +
> > > +       if (!p)
> > > +               return;
> > > +
> > > +       if (hex[0] == 's') {
> > > +               struct symbol *s = (struct symbol *)p;
> > > +
> > > +               sym = s;
> > > +               symbolInfo();
> > > +       } else {
> > > +               struct menu *m = (struct menu *)p;
> > > +
> > > +               _menu = m;
> > > +               menuInfo();
> > > +       }
> > > +       emit showDebugChanged(true);
> > > +}
> > > +
> > >  QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
> > >  {
> > >         QMenu* popup = Parent::createStandardContextMenu(pos);
> > > @@ -1497,6 +1527,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 *)),
> > > 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);
> > > --
> > > 2.26.2
> > >
> >
> >
>
>
Mauro Carvalho Chehab June 28, 2020, 3:51 p.m. UTC | #5
Em Sun, 28 Jun 2020 17:48:08 +0300
Maxim Levitsky <mlevitsk@redhat.com> escreveu:

> On Sun, 2020-06-28 at 23:41 +0900, Masahiro Yamada wrote:
> > On Sun, Jun 28, 2020 at 9:21 PM Mauro Carvalho Chehab
> > <mchehab+huawei@kernel.org> wrote:  
> > > The Qt5 conversion broke support for debug info links.
> > > 
> > > Restore the behaviour added by changeset
> > > ab45d190fd4a ("kconfig: create links in info window").
> > > 
> > > Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> > > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>  
> > 
> > I tested this patch, but this caused
> > segmentation fault.
> > 
> > 
> > I enabled 'Show Debug Info',
> > and then clicked
> > dep: <symbol name>.
> > 
> > Then, xconfig crashed.
> > 
> > (without this patch, it did not cause
> > segfault at least)
> > 
> > Did you see this?  
> 
> Works for me - tested this again 

It works for me too, but I'll double check. I don't actually like the
way it works, as it passes a pointer via the hyperlinks, instead of
some other type of reference, but this is the way the qt3 version
used to work.

I'll see if I can implement it on a different way, or at least add
some validation check.

Btw, what symbol did you click?

> (I have both patches applied on top on mainline master branch).
> Maybe you have Qt4?
> 
> One thing that I forgot to report is that when clicking on the symbol,
> only config descripion updates and not config/menu windows.
> It might even be always like that, I don't remember, but it would be nice if 
> these were updated too.

From what I saw this is the old behavior, at least as implemented on
changeset ab45d190fd4a ("kconfig: create links in info window").
See the implementation of ConfigInfoView::setSource() there.

I agree that it would be nice to change the other windows to reflect
it, but the goal of this patch is just to restore the old behavior.

A followup patch could be done later in order to improve it.

Regards,
Mauro
Mauro Carvalho Chehab June 28, 2020, 4:20 p.m. UTC | #6
Em Sun, 28 Jun 2020 23:41:46 +0900
Masahiro Yamada <masahiroy@kernel.org> escreveu:

> On Sun, Jun 28, 2020 at 9:21 PM Mauro Carvalho Chehab
> <mchehab+huawei@kernel.org> wrote:
> >
> > The Qt5 conversion broke support for debug info links.
> >
> > Restore the behaviour added by changeset
> > ab45d190fd4a ("kconfig: create links in info window").
> >
> > Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> > Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>  
> 
> 
> I tested this patch, but this caused
> segmentation fault.
> 
> 
> I enabled 'Show Debug Info',
> and then clicked
> dep: <symbol name>.
> 
> Then, xconfig crashed.
> 
> (without this patch, it did not cause
> segfault at least)
> 
> Did you see this?

Could you please try the attached version? It should validate again the
symbols, instead of relying on a pointer passed via an URL.

This version still passes pointers via URLs for menus, though,
as it doesn't implement any logic for seeking the menu->prompt
string.

With this version, if something bad happens when parsing a
symbol internal URL, the code will print a message and ignore
it.

Thanks,
Mauro

[PATCH] kconfig: qconf: make debug links work again

The Qt5 conversion broke support for debug info links.

Restore the behaviour added by changeset
ab45d190fd4a ("kconfig: create links in info window").

Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 631e19659504..7dae5c5989db 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());
@@ -1085,7 +1086,7 @@ void ConfigInfoView::menuInfo(void)
 			if (sym->name) {
 				head += " (";
 				if (showDebug())
-					head += QString().sprintf("<a href=\"s%p\">", sym);
+					head += QString().sprintf("<a href=\"s%s\">", sym->name);
 				head += print_filter(sym->name);
 				if (showDebug())
 					head += "</a>";
@@ -1094,7 +1095,7 @@ void ConfigInfoView::menuInfo(void)
 		} else if (sym->name) {
 			head += "<big><b>";
 			if (showDebug())
-				head += QString().sprintf("<a href=\"s%p\">", sym);
+				head += QString().sprintf("<a href=\"s%s\">", sym->name);
 			head += print_filter(sym->name);
 			if (showDebug())
 				head += "</a>";
@@ -1217,13 +1218,56 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
 	QString str2 = print_filter(str);
 
 	if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
-		*text += QString().sprintf("<a href=\"s%p\">", sym);
+		*text += QString().sprintf("<a href=\"s%s\">", sym->name);
 		*text += str2;
 		*text += "</a>";
 	} else
 		*text += str2;
 }
 
+void ConfigInfoView::clicked(const QUrl &url)
+{
+	QByteArray str = url.toEncoded();
+	const std::size_t count = str.size();
+	char *hex = new char[count + 1];
+	char type;
+	struct symbol **result;
+
+	if (count < 1) {
+		qInfo() << "Clicked link is empty";
+		return;
+	}
+
+	memcpy(hex, str.constData(), count);
+	type = hex[0];
+
+	if (type == 's') {
+		/* Seek for exact match */
+		hex[0] = '^';
+		strcat(hex, "$");
+		result = sym_re_search(hex);
+		if (!result) {
+			qInfo() << "Clicked symbol is invalid";
+			return;
+		}
+
+		sym = *result;
+		symbolInfo();
+	} else {
+		unsigned long p = (int)strtol(hex + 1, NULL, 16);
+		if (!p) {
+			qInfo() << "Clicked menu is invalid";
+			return;
+		}
+
+		struct menu *m = (struct menu *)p;
+
+		_menu = m;
+		menuInfo();
+	}
+	emit showDebugChanged(true);
+}
+
 QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
 {
 	QMenu* popup = Parent::createStandardContextMenu(pos);
@@ -1497,6 +1541,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 *)),
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);

Patch
diff mbox series

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 631e19659504..03cadf27a376 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1012,7 +1012,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 +1224,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;
+
+	if (count < 1)
+		return;
+
+	memcpy(hex, str.constData(), count);
+	p = (int)strtol(hex + 1, NULL, 16);
+
+	if (!p)
+		return;
+
+	if (hex[0] == 's') {
+		struct symbol *s = (struct symbol *)p;
+
+		sym = s;
+		symbolInfo();
+	} else {
+		struct menu *m = (struct menu *)p;
+
+		_menu = m;
+		menuInfo();
+	}
+	emit showDebugChanged(true);
+}
+
 QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
 {
 	QMenu* popup = Parent::createStandardContextMenu(pos);
@@ -1497,6 +1527,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 *)),
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);