platform: register singleton instance early with NM_PLATFORM_REGISTER_SINGLETON

Add a construct-only property NM_PLATFORM_REGISTER_SINGLETON to NMPlatform.
When set to TRUE, the constructor will self-register to nm_platform_setup().

The reason for this is that the _LOG() macro in NMLinuxPlatform logs the
self pointer if the instance is not the singleton instance.

During construction, we already have many log lines due to initialization
of the instance. These lines all end up qualified with the self pointer.
By earlier self-registering, printing the pointer value is omitted.

Yes, this patch is really just to prettify logging.
This commit is contained in:
Thomas Haller
2015-05-12 07:34:56 +02:00
parent f1f1c3cb73
commit 56b07b1a3f
3 changed files with 59 additions and 1 deletions

View File

@@ -429,7 +429,9 @@ G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM)
void
nm_linux_platform_setup (void)
{
nm_platform_setup (g_object_new (NM_TYPE_LINUX_PLATFORM, NULL));
g_object_new (NM_TYPE_LINUX_PLATFORM,
NM_PLATFORM_REGISTER_SINGLETON, TRUE,
NULL);
}
/******************************************************************/