All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Maxim Levitsky <mlevitsk@redhat.com>,
	Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 4/5] kconfig: qconf: make debug links work again
Date: Tue, 30 Jun 2020 12:48:13 +0900	[thread overview]
Message-ID: <CAK7LNARkzq=D8hhqYERcjRzv5LXsepunQCX8rhG7nORZuBAj7Q@mail.gmail.com> (raw)
In-Reply-To: <b10b8bf2c21f4288ecb6081a967c302000346ff1.1593423060.git.mchehab+huawei@kernel.org>

On Mon, Jun 29, 2020 at 6:35 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").
>
> The original approach were to pass a pointer for a data struct

"were" -> "was" ?


> via an <a href>. That doesn't sound a good idea, as, if something
> gets wrong, the app could crash. So, instead, pass the name of
> the symbol, and validate such symbol at the hyperlink handling
> logic.
>
> Link: https://lore.kernel.org/lkml/20200628125421.12458086@coco.lan/
> Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>



This patch does not cause segmentation fault any more.
Thanks.


> ---
>  scripts/kconfig/qconf.cc | 75 +++++++++++++++++++++++++++++++++++++---
>  scripts/kconfig/qconf.h  |  1 +
>  2 files changed, 71 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> index 85782da3e464..49f0688fceb8 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>";
> @@ -1145,7 +1146,7 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
>                 switch (prop->type) {
>                 case P_PROMPT:
>                 case P_MENU:
> -                       debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
> +                       debug += QString().sprintf("prompt: <a href=\"m%s\">", sym->name);
>                         debug += print_filter(prop->text);
>                         debug += "</a><br>";
>                         break;
> @@ -1217,13 +1218,74 @@ 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 *data = new char[count + 1];
> +       struct symbol **result;
> +       struct menu *m = NULL;
> +       char type;
> +
> +       if (count < 1) {
> +               qInfo() << "Clicked link is empty";
> +               delete data;
> +               return;
> +       }
> +
> +       memcpy(data, str.constData(), count);
> +       data[count] = '\0';
> +       type = data[0];
> +
> +       /* Seek for exact match */
> +       data[0] = '^';
> +       strcat(data, "$");
> +       result = sym_re_search(data);
> +       if (!result) {
> +               qInfo() << "Clicked symbol is invalid:" << data;
> +               delete data;
> +               return;
> +       }
> +
> +       sym = *result;
> +       if (type == 's') {
> +               symbolInfo();
> +               emit showDebugChanged(true);
> +               free(result);
> +               delete data;
> +               return;
> +       }
> +
> +       /* URL is a menu */
> +       for (struct property *prop = sym->prop; prop; prop = prop->next) {
> +                   if (prop->type != P_PROMPT && prop->type != P_MENU)
> +                           continue;
> +                   m = prop->menu;
> +                   break;
> +       }
> +
> +       if (!m) {
> +               qInfo() << "Clicked menu is invalid:" << data;
> +               free(result);
> +               delete data;
> +               return;
> +       }
> +
> +       _menu = m;
> +       menuInfo();
> +
> +       emit showDebugChanged(true);
> +       free(result);
> +       delete data;
> +}
> +
>  QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
>  {
>         QMenu* popup = Parent::createStandardContextMenu(pos);
> @@ -1497,6 +1559,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
>


-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2020-06-30  3:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29  9:35 [PATCH v2 0/5] Fix split view search and debug info navigation Mauro Carvalho Chehab
2020-06-29  9:35 ` Mauro Carvalho Chehab
2020-06-29  9:35 ` [PATCH v2 1/5] kconfig: qconf: cleanup includes Mauro Carvalho Chehab
2020-06-29  9:35   ` Mauro Carvalho Chehab
2020-06-29  9:35 ` [PATCH v2 2/5] kconfig: qconf: ensure that only one item will be highlighted Mauro Carvalho Chehab
2020-06-29  9:35   ` Mauro Carvalho Chehab
2020-06-29  9:35 ` [PATCH v2 3/5] kconfig: qconf: make search fully work again on split mode Mauro Carvalho Chehab
2020-06-29  9:35   ` Mauro Carvalho Chehab
2020-06-29  9:35 ` [PATCH v2 4/5] kconfig: qconf: make debug links work again Mauro Carvalho Chehab
2020-06-29  9:35   ` Mauro Carvalho Chehab
2020-06-30  3:48   ` Masahiro Yamada [this message]
2020-06-29  9:35 ` [PATCH v2 5/5] kconfig: qconf: navigate menus on hyperlinks Mauro Carvalho Chehab
2020-06-29  9:35   ` Mauro Carvalho Chehab
2020-06-30  2:49   ` Masahiro Yamada
2020-06-30  3:36   ` Masahiro Yamada
2020-06-30  6:25     ` Mauro Carvalho Chehab
2020-06-29 10:57 ` [PATCH] kconfig: qconf: re-implement setSelected() Mauro Carvalho Chehab
2020-06-29 10:57   ` Mauro Carvalho Chehab
2020-06-29 12:23 ` [PATCH v2 0/5] Fix split view search and debug info navigation Maxim Levitsky
2020-06-29 14:46   ` Mauro Carvalho Chehab
2020-06-29 14:58     ` Maxim Levitsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK7LNARkzq=D8hhqYERcjRzv5LXsepunQCX8rhG7nORZuBAj7Q@mail.gmail.com' \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=mlevitsk@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.