[easytag/wip/et_core-refactor: 1/2] Simplify ET_Core from four functions to two
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/et_core-refactor: 1/2] Simplify ET_Core from four functions to two
- Date: Wed, 31 Dec 2014 16:05:29 +0000 (UTC)
commit 94da689bccf1dc291eebe08f2db2ae77e156f183
Author: David King <amigadave amigadave com>
Date: Wed Dec 31 11:08:57 2014 +0000
Simplify ET_Core from four functions to two
Remove the duplication of create/initialize and free/destroy to just
ET_Core_Create() and ET_Core_Free().
src/application.c | 2 +-
src/application_window.c | 5 ++++-
src/easytag.c | 4 ++--
src/et_core.c | 31 ++++---------------------------
src/et_core.h | 6 ++----
5 files changed, 13 insertions(+), 35 deletions(-)
---
diff --git a/src/application.c b/src/application.c
index 72a8212..a970cc4 100644
--- a/src/application.c
+++ b/src/application.c
@@ -111,7 +111,7 @@ on_idle_init (EtApplication *self)
priv = et_application_get_instance_private (self);
ET_Core_Free ();
- ET_Core_Initialize ();
+ ET_Core_Create ();
if (g_settings_get_boolean (MainSettings, "scan-startup"))
{
diff --git a/src/application_window.c b/src/application_window.c
index e400b0c..db1318f 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -1592,7 +1592,10 @@ et_application_window_dispose (GObject *object)
save_state (self);
- ET_Core_Destroy ();
+ if (ETCore)
+ {
+ ET_Core_Free ();
+ }
if (priv->cddb_dialog)
{
diff --git a/src/easytag.c b/src/easytag.c
index 13b91d9..d48810e 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -920,8 +920,8 @@ Read_Directory (const gchar *path_real)
ReadingDirectory = TRUE; /* A flag to avoid to start another reading */
/* Initialize file list */
- ET_Core_Free();
- ET_Core_Initialize();
+ ET_Core_Free ();
+ ET_Core_Create ();
et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
window = ET_APPLICATION_WINDOW (MainWindow);
diff --git a/src/et_core.c b/src/et_core.c
index e08bc46..ebe33c0 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -36,31 +36,16 @@ ET_Core_Create (void)
/* Allocate. */
if (ETCore == NULL)
{
- ETCore = g_slice_new (ET_Core);
+ ETCore = g_slice_new0 (ET_Core);
}
-
- /* Initialize. */
- ET_Core_Initialize ();
-}
-
-void
-ET_Core_Initialize (void)
-{
- ETCore->ETFileList = NULL;
- ETCore->ETFileDisplayedList = NULL;
- ETCore->ETFileDisplayedListPtr = NULL;
- ETCore->ETFileDisplayedList_Length = 0;
- ETCore->ETFileDisplayedList_TotalSize = 0;
- ETCore->ETFileDisplayedList_TotalDuration = 0;
- ETCore->ETFileDisplayed = NULL;
- ETCore->ETHistoryFileList = NULL;
- ETCore->ETArtistAlbumFileList = NULL;
}
void
ET_Core_Free (void)
{
- // Frees first lists, then initialize
+ g_return_if_fail (ETCore != NULL);
+
+ /* First frees lists. */
if (ETCore->ETFileList)
ET_Free_File_List();
@@ -73,16 +58,8 @@ ET_Core_Free (void)
if (ETCore->ETArtistAlbumFileList)
ET_Free_Artist_Album_File_List();
- // Initialize by security
- ET_Core_Initialize();
-}
-
-void
-ET_Core_Destroy (void)
-{
if (ETCore)
{
- ET_Core_Free ();
g_slice_free (ET_Core, ETCore);
ETCore = NULL;
}
diff --git a/src/et_core.h b/src/et_core.h
index 1afb9a3..1fb6bfe 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -61,10 +61,8 @@ typedef struct
extern ET_Core *ETCore; /* Main pointer to structure needed by EasyTAG. */
-void ET_Core_Create (void);
-void ET_Core_Initialize (void);
-void ET_Core_Free (void);
-void ET_Core_Destroy (void);
+void ET_Core_Create (void);
+void ET_Core_Free (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]