Merge lp://qastaging/~compiz-team/compiz/compiz.ccs_general_cleanup into lp://qastaging/compiz/0.9.8

Proposed by Sam Spilsbury
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3323
Merged at revision: 3317
Proposed branch: lp://qastaging/~compiz-team/compiz/compiz.ccs_general_cleanup
Merge into: lp://qastaging/compiz/0.9.8
Diff against target: 3282 lines (+1116/-567)
35 files modified
cmake/CompizCommon.cmake (+17/-2)
compizconfig/gconf/src/gconf.c (+11/-10)
compizconfig/gsettings/src/gsettings.c (+2/-2)
compizconfig/libcompizconfig/backend/src/ini.c (+14/-11)
compizconfig/libcompizconfig/include/ccs-backend.h (+10/-2)
compizconfig/libcompizconfig/include/ccs-defs.h (+93/-0)
compizconfig/libcompizconfig/include/ccs-list.h (+85/-0)
compizconfig/libcompizconfig/include/ccs-object.h (+204/-0)
compizconfig/libcompizconfig/include/ccs-string.h (+47/-0)
compizconfig/libcompizconfig/include/ccs.h (+27/-204)
compizconfig/libcompizconfig/src/ccs-private.h (+2/-6)
compizconfig/libcompizconfig/src/compiz.cpp (+20/-18)
compizconfig/libcompizconfig/src/ini.c (+1/-1)
compizconfig/libcompizconfig/src/lists.c (+2/-2)
compizconfig/libcompizconfig/src/main.c (+178/-168)
compizconfig/libcompizconfig/tests/CMakeLists.txt (+1/-0)
compizconfig/libcompizconfig/tests/context-mock.cpp (+3/-2)
compizconfig/libcompizconfig/tests/mock-context.h (+29/-9)
compizconfig/libcompizconfig/tests/mock-plugin.h (+21/-3)
compizconfig/libcompizconfig/tests/mock-setting.h (+18/-5)
compizconfig/libcompizconfig/tests/plugin-mock.cpp (+3/-2)
compizconfig/libcompizconfig/tests/setting-mock.cpp (+32/-4)
compizconfig/libcompizconfig/tests/test-ccs-object.cpp (+1/-77)
compizconfig/libcompizconfig/tests/test-context.cpp (+1/-1)
compizconfig/libcompizconfig/tests/test-plugin.cpp (+1/-1)
compizconfig/libcompizconfig/tests/test-setting.cpp (+1/-1)
compizconfig/tests/compizconfig_ccs_mocked_allocator.h (+95/-0)
gtk/gnome/50-compiz-launchers.xml.in (+6/-0)
gtk/gnome/50-compiz-navigation.xml.in (+74/-0)
gtk/gnome/50-compiz-screenshot.xml.in (+8/-0)
gtk/gnome/50-compiz-system.xml.in (+8/-0)
gtk/gnome/50-compiz-windows.xml.in (+32/-0)
gtk/gnome/CMakeLists.txt (+28/-0)
gtk/window-decorator/settings.c (+36/-36)
po/POTFILES.in (+5/-0)
To merge this branch: bzr merge lp://qastaging/~compiz-team/compiz/compiz.ccs_general_cleanup
Reviewer Review Type Date Requested Status
Tim Penhey (community) Needs Information
Review via email: mp+118482@code.qastaging.launchpad.net

This proposal supersedes a proposal from 2012-08-07.

Commit message

Fix some memory management issues on the mock objects, namely:
 * Make destructor functions virtual where appropriate, so that we can add them to lists polymorphically
 * Support polymorphic ccs*Unref function

Also make some other neccessary changes to libcompizconfig

 * Comparison of bool values in lists must be done through boolean operators
 * expose the definition of ccsCopyList, other programs will need it.

Description of the change

Fix some memory management issues on the mock objects, namely:
 * Make destructor functions virtual where appropriate, so that we can add them to lists polymorphically
 * Support polymorphic ccs*Unref function

Also make some other neccessary changes to libcompizconfig

 * Comparison of bool values in lists must be done through boolean operators
 * expose the definition of ccsCopyList, other programs will need it.

Next: https://code.launchpad.net/~compiz-team/compiz/compiz.ccs_pull_mocks_into_compizconfig_dir/+merge/118483

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

> compizconfig/gconf/src/gconf.c

Why change array to be "const char**" ? Also why cast it in free?

> compizconfig/gsettings/src/gsettings.c

Casting "const gchar**" to "char**"? Surely that should be "gchar**" if anything.

Why add the "const" if it is only causing pain?

I personally dislike TRUE being defined to ~0, but that's just me (other places define it to be 1).

Shouldn't !FALSE == TRUE? Pretty sure !0 is defined to be 1.

> compizconfig/tests/compizconfig_ccs_mocked_allocator.h

Header files should stand alone. here you are using stuff from <gmock/gmock.h>

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

free(void*) and g_free(void*) means those functions can accept any pointer type EXCEPT a pointer to const data.

The reason why they don't accept "const void *" is to honour the const properly. Freeing memory means the system is taking over it again and hence will write to it. free() would give the wrong message if it accepted "const void *" and hence any type of pointer.

The two solutions are:
  1. Dynamically allocated memory should never be assigned to const pointers; or
  2. Cast all pointers to non-const on free: free((void*)p)

I don't see either option being much better than the other. Although #1 (removing the const) makes for slightly simpler code.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> > compizconfig/gconf/src/gconf.c
>
> Why change array to be "const char**" ? Also why cast it in free?
>
> > compizconfig/gsettings/src/gsettings.c
>
> Casting "const gchar**" to "char**"? Surely that should be "gchar**" if
> anything.
>
> Why add the "const" if it is only causing pain?

Yep, you're completely right, I am an idiot. ccsSetValueListFromStringArray takes const char ** now, and I just changed the declaration to get around the error. A better way of doing this:

gchar **array = calloc (1, sizeof (gchar *));

ccsSetValueListFromStringArray ((const gchar **) array);

g_strfreev (array);
>
> I personally dislike TRUE being defined to ~0, but that's just me (other
> places define it to be 1).
>
> Shouldn't !FALSE == TRUE? Pretty sure !0 is defined to be 1.

Yep it does suck, I don't know what kind of subtle bugs we might encounter though if we change the definition right now, so I'd prefer to leave it as is for the time being.

>
> > compizconfig/tests/compizconfig_ccs_mocked_allocator.h
>
> Header files should stand alone. here you are using stuff from
> <gmock/gmock.h>

Ack, fixed.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches