Page MenuHome

WIP: Make logs show in info editor
Needs ReviewPublic

Authored by Mateusz Grzeliński (grzelins) on Jun 29 2020, 10:33 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Maniphest Tasks
T78214: Make log appear in Info Editor
Summary

Status: Please abandon this diff, changes will be introduced in D8677: Add core functionalities from GSoC Info Editor Improvements

This is highly experimental implementation of T78214 for GSoC project, it has quite a few problems with memory.

  • clog context now stores logs as list
  • info editor can show reports from window manager of log context
  • logs from clog context are converted to reports

Diff Detail

Repository
rB Blender
Branch
add-log-report (branched from master)
Build Status
Buildable 8745
Build 8745: arc lint + arc unit

Event Timeline

Mateusz Grzeliński (grzelins) requested review of this revision.Jun 29 2020, 10:33 AM
Mateusz Grzeliński (grzelins) created this revision.
Mateusz Grzeliński (grzelins) added a project: Restricted Project.
Mateusz Grzeliński (grzelins) edited the summary of this revision. (Show Details)

Did a first review pass.

noted several things re linklist usage, but in fact iirc code in internis not supposed to link anything from source, so you should probably define your own basic list code instead? CC @Brecht Van Lommel (brecht), @Sergey Sharybin (sergey) or @Campbell Barton (campbellbarton) can you confirm that?

intern/clog/CLG_log.h
156

Can't you keep this struct private (in its own C file), and instead accessors to the few items you actually need to expose (would expect only the list of CLG_LogRecord ?)

This should also avoid the need to link ListBase headers here (we avoid as much as possible linking headers into other headers)

intern/clog/clog.c
343–344

No need to init this to NULL since you already use calloc ;)

605

Please do not change that, using dereferenced pointer as size indicator is preferred way to do in Blender code (that way if you e.g. change type of ctx you do not risk missing to update that sizeof clause ).

611–612

better to use BLI_listbase_clear

620–626

This could be done in a (less verbose) for loop.

Also please use BLI_listbase_clear at the end

source/blender/editors/space_info/info_report.c
44

You should rather edit the relevant CMake file to add that intern module in the path? And also add build dependency on it, probably

157–159

Can switch those two, then you can use reports directly to get report

422

You probably want to change the type of report depending on type or severity of the log?

source/blender/editors/space_info/space_info.c
96–109

This looks very suspicious to me? You borrow reference of wm->reports into sinfo->active_reports, but then free them from the space data??? Think you should check in which mode the space info is at init time? Or at the very least add a comment stating that it is never in INFO_VIEW_G_CLOG in init function (if that is the case).

Also please set pointer to NULL after having freed the space data.

115

yes, definitively ;)

source/blender/makesdna/DNA_space_types.h
126

Please use a more generic name, not tied up to some specific internal tool (like e.g. INFO_VIEW_LOG

source/blender/makesrna/intern/rna_space_api.c
41–42

Should probably ensure that this is not NULL? At least with an BLI_assert if it ixs never expected to be.

Also, should ensure those reports were generated from clog, and not already from WM? You cannot really rely on this update call being only called from one specific RNA property change, seems very weak.

And finally, some other code in C might directly change the DNA value, completely by-passing the RNA update.

So what I would do here is:

  • Handle this switch of reports source in spaceinfo update function.
  • Store in spaceinfo the current source of its active_reports.
  • use that info and current mode to know whether you need to update to active_reports, and free them first, etc. (in the space info update function).

then that RNA update callback should only tag the space info for update.

47

Think you need to free existing ones first here as well?

intern/clog/CLG_log.h
102

Why do you even need to expose this publicly actually?

Mateusz Grzeliński (grzelins) marked 7 inline comments as done.

Address comments

intern/clog/CLG_log.h
102

it was only for clog_to_report_list. It will be unnecessary when I create access function for g_ctx->log_records

source/blender/editors/space_info/info_report.c
422

yes, this is todo

source/blender/makesrna/intern/rna_space_api.c
41–42

Which info update callback are you talking about?
It is callback in SpaceType draw or refresh?

  • art->draw = info_main_region_draw;
  • SpaceType->refresh

Or maybe I shall create new tag?

  • WM_main_add_notifier(NC_SPACE | ND_SPACE_INFO_CHANGE_VIEW, log_record);
  • or reuse existing tag ND_SPACE_INFO_REPORT and only check SpaceInfo->view and SpaceInfo->active_reports to check if source has changed

WIP: Further development

  • join file and line in CLG_LogRecord
  • convert clog to dynamically allocated message
  • add function for deep copy record list
  • remove custom enum update callback in favor of update on tag
  • ui tweak
Mateusz Grzeliński (grzelins) marked an inline comment as done.
  • Tweaks for memory management
  • Add todo

Sanitize pointer on startup

noted several things re linklist usage, but in fact iirc code in internis not supposed to link anything from source, so you should probably define your own basic list code instead? CC @Brecht Van Lommel (brecht), @Sergey Sharybin (sergey) or @Campbell Barton (campbellbarton) can you confirm that?

It's indeed not the intention to include code from source in intern. If this leads to significant duplicated code, I suggest we move clog into source/blender so that we can use blenlib and similar.

I don't think it makes sense for this module to include DNA_windowmanager_types however.

  • Remove clog dependency on ListBase

Currently this diff can be run only with --factory-startup, not sure what is the issue

Mateusz Grzeliński (grzelins) retitled this revision from WIP: Make reports show in info editor to WIP: Make logs show in info editor.Jul 5 2020, 3:01 PM