Improve opengl debug messages
ClosedPublic

Authored by apol on May 12 2020, 5:05 PM.

Details

Summary

Don't include the \n at the end of the debug messages

Test Plan

Now I can see the debug errors without an empty line below

Diff Detail

Repository
R108 KWin
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 26797
Build 26815: arc lint + arc unit
apol created this revision.May 12 2020, 5:05 PM
Restricted Application added a project: KWin. · View Herald TranscriptMay 12 2020, 5:05 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
apol requested review of this revision.May 12 2020, 5:05 PM
zzag added a subscriber: zzag.May 12 2020, 5:16 PM
zzag added inline comments.
plugins/scenes/opengl/scene_opengl.cpp
420

Noob question: what is going to happen if length is 0?

apol added a comment.May 12 2020, 5:52 PM

I'm expecting QDebug would handle it, I don't see why opengl would be giving us an empty debug message though.

zzag added inline comments.May 12 2020, 5:55 PM
plugins/scenes/opengl/scene_opengl.cpp
414–415

Hmm, why doesn't this code work?

zzag added inline comments.May 12 2020, 6:04 PM
plugins/scenes/opengl/scene_opengl.cpp
414–415

It's quite possible that we have an off by one error here.

apol updated this revision to Diff 82869.May 14 2020, 4:16 PM

we were landing on \0 so we never reached \n

apol marked 3 inline comments as done.May 14 2020, 4:20 PM
zzag added inline comments.May 14 2020, 4:36 PM
plugins/scenes/opengl/scene_opengl.cpp
414
while (message[length] == '\0')
    length--;

will cutoff the last character, e.g. if we have "abcd\0" then only "abc" will be printed. More conservative trimming algorithm will look something like this

while (message[length - 1] == '\n' || message[length - 1] == '\r')
    --length;
zzag added inline comments.May 14 2020, 4:46 PM
plugins/scenes/opengl/scene_opengl.cpp
414
while (length && isspace(message[length - 1])
    --length;

this one is a bit more safer

apol updated this revision to Diff 82875.May 14 2020, 6:30 PM

As suggested by zzag

zzag accepted this revision.May 15 2020, 5:49 AM
This revision is now accepted and ready to land.May 15 2020, 5:49 AM
This revision was automatically updated to reflect the committed changes.