[Merge] ~kondor-dani/compiz:annotate_fix into compiz:master
Daniel Kondor
kondor.dani at gmail.com
Thu May 14 13:11:48 UTC 2020
The example works (on this branch), since the draw() function fills in everything with default values.
Full example would be e.g.:
dbus-send --print-reply --type=method_call --dest=org.freedesktop.compiz /org/freedesktop/compiz/annotate/screen0/draw org.freedesktop.compiz.activate string:root int32:416 string:tool string:line string:x1 double:100.0 string:y1 double:200.0 string:x2 double:200.0 string:y2 double:300.0 string:fill_color string:"#ff00ffff"
Diff comments:
> diff --git a/plugins/annotate/src/annotate.cpp b/plugins/annotate/src/annotate.cpp
> index f415d6c..7492de7 100644
> --- a/plugins/annotate/src/annotate.cpp
> +++ b/plugins/annotate/src/annotate.cpp
> @@ -299,10 +299,12 @@ AnnoScreen::draw (CompAction *action,
>
> if (cr)
> {
> + std::string tool_str;
> const char *tool;
> unsigned short *fillColor, *strokeColor;
>
> - tool = CompOption::getStringOptionNamed (options, "tool", "line").c_str ();
> + tool_str = CompOption::getStringOptionNamed (options, "tool", "line");
> + tool = tool_str.c_str ();
Added demonstration in branch:
https://code.launchpad.net/~kondor-dani/compiz/+git/compiz/+ref/annotate_tool_error
(simple print statement with the value)
Looking at CompOption::getStringOptionNamed (include/core/option.h) it returns an rvalue CompString (typedef for std::string), so it is a temporary that will go out of scope if not assigned to a local variable. It can work in other places if the memory location returned by c_str() is not overwritten by another call.
>
> cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
> cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
--
https://code.launchpad.net/~kondor-dani/compiz/+git/compiz/+merge/383948
Your team Compiz Maintainers is subscribed to branch compiz:master.
More information about the Ubuntu-reviews
mailing list