Bug 427050 - The classes toolview does not work--no classes displayed
Summary: The classes toolview does not work--no classes displayed
Status: RESOLVED NOT A BUG
Alias: None
Product: kdevelop
Classification: Applications
Component: UI: general (other bugs)
Version First Reported In: 5.6.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-27 22:09 UTC by kdbase-kdebug
Modified: 2020-09-30 19:36 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Sample C++ program (271 bytes, text/x-c++src)
2020-09-30 18:58 UTC, kdbase-kdebug
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kdbase-kdebug 2020-09-27 22:09:29 UTC
SUMMARY


STEPS TO REPRODUCE
1. Open an existing project with C++ classes.
2. Click on Classes toolview button.
3. Select All projects classes or the current project classes

OBSERVED RESULT
The list of classes is empty.

EXPECTED RESULT
Show class hierarchy, with all classes, members, etc.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma:
(available in About System)
KDE Plasma Version: 5.19.5
KDE Frameworks Version: 5.73.0
Qt Version: 5.15.1

ADDITIONAL INFORMATION

This has been going on for several months.  I am currently on Fedora, but it's the same on Arch Linux and Debian sid.  The class parser works fine.  If I hover over a variable, it shows all the information about the variable, such as where it's declared and defined.  I can go to these locations, see where the variable is used, etc.  These features are more important, for me at least, than the Classes toolview, but the toolview is also nice.  It appears that no one else has reported this, but I cannot find any error in my configuration.  It worked well until a few months ago.
Comment 1 Francis Herne 2020-09-27 22:31:16 UTC
I can't reproduce this with 5.6-git on Arch, the Classes toolview is working fine.

Do you have an example of a specific project this doesn't work with?

(also, can you please set the 'Version' field?)
Comment 2 kdbase-kdebug 2020-09-28 15:54:14 UTC
Francis,

Thanks for you reply. I'm not surprised that you say you can't reproduce it, since no one else has reported it. For some mysterious reason, I seem to be the only person affected.

I filled in the version field to 5.6.0.  It also happened with the previous version of kdevelop.

You may want to close the bug. My project is small, so I can try to create a new project and session, or even re-install kdevelop, to see if that fixes the problem for me.  If it does, I'll post an update.
Comment 3 kdbase-kdebug 2020-09-29 02:25:22 UTC
As promised, here's a followup.

The Classes toolview is working properly now.  I deleted and re-created the project, and then did--I did a lot of things.  I'm not entirely sure what finally worked.

The project is something I've been tinkering with for several years.  It was originally created with a text editor outside of kdevelop, and later integrated with the IDE (which is very good, by the way).  Later on, I switched from using a makefile to using meson.

Everything always worked fine, until the Classes button quit doing anything a few months ago.  Until today, I always ran the meson command outside of kdevelop, and used kdevelop just for its editing, searching, etc. capabilities.  Just in the last few minutes, I set up kdevelop to itself build the project, using meson, and this is what finally made the Classes button work as before.

As I mentioned before, the classes were always parsed properly, and I could hover over a variable in the code and get all the information about it.  I think it would be better if the Classes button also worked, but this was a minor problem.  Perhaps the documenation could be clearer for my use case, or perhaps it's not worth worrying about.
Comment 4 Francis Herne 2020-09-29 11:16:53 UTC
Thank you for the report.

Given that it only seems to happen for you, it's presumably caused by some attribute of your project or setup and unlikely to be reproducible given the information available.

If the project is publicly-available somewhere (or you can attach it here or send it to me) I could try with that.

Documentation is probably not an issue -- there's no case where classes should be visible in the code browser and not the Classes view.

P.S. -- meson support in KDevelop is quite recent, it might not have existed when you originally imported the project.
Comment 5 kdbase-kdebug 2020-09-30 18:58:37 UTC
Created attachment 132030 [details]
Sample C++ program

Attachment for bug number 427050
Comment 6 kdbase-kdebug 2020-09-30 19:18:18 UTC
I have reproduced the problem.  I'll explain how here, and then I'll explain how it happened to me.

1. Create a new directory, for example 'test'.

2. Copy the file 'junk.cpp' into the directory.  I just tried uploading the file as an attachment, but I'm not sure it uploaded it correctly.  Since the file is short, I'll place the contents here:

---------------------------------------------------------------
// Sample file

#include <iostream>

struct junk {
  long a;
  double b;
  junk() {
    a = 2;
    b = 3.5;
  }
  void out() const {
    std::cout << "a = " << a << ", b = " << b << '\n';
  }
};

int main()
{
  junk j0;
  j0.out();
  j0.b *= 3;
  j0.out();
  return 0;
}
---------------------------------------------------------------

3. Open kdevelop.  From the menu bar, choose 'New from Template...' under 'Project'.  Choose 'Standard' Category, 'Empty' Project Type.  You can probably place the project anywhere, but I chose to place it in the test/ directory.  I named the project 'ex'.

4. Open the newly created project 'ex'.  It contains no files.  Using the 'File System' tab on the left, or maybe using the 'File' menu, open the file 'junk.cpp'.

5. This re-creates the problem.  The junk.cpp file is in the editor.  If you click on the Classes tab, the junk struct is not present.  Within the editor, however, you can access the information about variables and objects.  For example, you can hover over the 'out' on line 20, or the 'b' on line 21.  At least, this is the behavior I observe.


How did this happen to me?  In my case, I had an existing project that used meson.  At first, as Francis guessed, kdevelop did not support meson.  When it was added later, I couldn't figure out how to use it, although I didn't try very hard.  There was (and is, I think) no template to create a new meson project, so I chose the Empty Project Type and added the source files afterwards.

I hope this is clear.  Please let me know if you have questions.
Comment 7 Francis Herne 2020-09-30 19:36:46 UTC
Thank you for the detailed explanation, now I see what's happened.

Also, it's a documentation (or at least a don't-use-it-that-way) issue. :D

When you create the new project 'ex', it creates a new directory `test/ex/` as the project root.

Because `test/junk.cpp` is outside that directory, it isn't part of the project.

The "Classes" view only shows classes from open projects (my last comment "there's no case where..." was wrong...), so doesn't show those from `junk.cpp`.

If you want to import a project with existing files, you shouldn't use "New from Template". Instead use "Open/Import Project" and select the existing directory -- if the buildsystem isn't supported, there will be a 'Custom Build System' option where you can enter the relevant configure/build commands manually.

Resolving as no immediate bug -- we might want to consider adding classes from open non-project files to the toolview, and/or making sure the manual is clear.