[beast: 10/49] BSE: remove explicit use_count on projects, leave reference counting to Bse::ProjectHandle
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 10/49] BSE: remove explicit use_count on projects, leave reference counting to Bse::ProjectHandle
- Date: Wed, 1 Jul 2015 11:29:56 +0000 (UTC)
commit 681f7038a1e1e9c1cf9993fe7f6a740a91a53c61
Author: Tim Janik <timj gnu org>
Date: Sun Jun 21 19:41:42 2015 +0200
BSE: remove explicit use_count on projects, leave reference counting to Bse::ProjectHandle
beast-gtk/bstapp.cc | 10 +-------
beast-gtk/bstfiledialog.cc | 3 +-
beast-gtk/bstmain.cc | 15 +++----------
beast-gtk/bstplayback.cc | 4 +--
bse/bseapi.idl | 2 +-
bse/bseserver.cc | 45 ++++++++++++++-----------------------------
bse/bseserver.hh | 4 +--
7 files changed, 25 insertions(+), 58 deletions(-)
---
diff --git a/beast-gtk/bstapp.cc b/beast-gtk/bstapp.cc
index dabcdb6..387c209 100644
--- a/beast-gtk/bstapp.cc
+++ b/beast-gtk/bstapp.cc
@@ -337,7 +337,6 @@ bst_app_destroy (GtkObject *object)
"any_signal", bst_app_reload_pages, self,
"any_signal", gxk_widget_update_actions, self,
NULL);
- bse_item_unuse (self->project.proxy_id());
self->project = Bse::ProjectH(); // NULL
}
@@ -366,7 +365,6 @@ bst_app_finalize (GObject *object)
"any_signal", bst_app_reload_pages, self,
"any_signal", gxk_widget_update_actions, self,
NULL);
- bse_item_unuse (self->project.proxy_id());
self->project = Bse::ProjectH(); // NULL
}
if (self->ppages)
@@ -390,7 +388,6 @@ bst_app_new (Bse::ProjectH project)
gxk_dialog_set_sizes (GXK_DIALOG (self), 500, 400, 950, 800);
self->project = project;
- bse_item_use (self->project.proxy_id());
bse_proxy_connect (self->project.proxy_id(),
"swapped_signal::item-added", bst_app_reload_pages, self,
"swapped_signal::item-remove", bst_app_reload_pages, self,
@@ -711,7 +708,7 @@ demo_play_song (gpointer data,
size_t callback_action)
{
const gchar *file_name = demo_entries[callback_action - BST_ACTION_LOAD_DEMO_0000].file;
- Bse::ProjectH project = bse_server.use_new_project (file_name);
+ Bse::ProjectH project = bse_server.create_project (file_name);
BseErrorType error = bst_project_restore_from_file (project, file_name, TRUE, TRUE);
if (error)
bst_status_eprintf (error, _("Opening project `%s'"), file_name);
@@ -725,7 +722,6 @@ demo_play_song (gpointer data,
gxk_status_window_pop ();
gxk_idle_show_widget (GTK_WIDGET (app));
}
- bse_item_unuse (project.proxy_id());
}
static GxkActionList*
@@ -865,11 +861,9 @@ app_action_exec (gpointer data,
case BST_ACTION_NEW_PROJECT:
if (1)
{
- Bse::ProjectH project = bse_server.use_new_project ("Untitled.bse");
-
+ Bse::ProjectH project = bse_server.create_project ("Untitled.bse");
bse_project_get_wave_repo (project.proxy_id());
BstApp *new_app = bst_app_new (project);
- bse_item_unuse (project.proxy_id());
gxk_idle_show_widget (GTK_WIDGET (new_app));
}
diff --git a/beast-gtk/bstfiledialog.cc b/beast-gtk/bstfiledialog.cc
index 663491b..7c0d886 100644
--- a/beast-gtk/bstfiledialog.cc
+++ b/beast-gtk/bstfiledialog.cc
@@ -411,7 +411,7 @@ static gboolean
bst_file_dialog_open_project (BstFileDialog *self,
const gchar *file_name)
{
- Bse::ProjectH project = bse_server.use_new_project (file_name);
+ Bse::ProjectH project = bse_server.create_project (file_name);
BseErrorType error = bst_project_restore_from_file (project, file_name, TRUE, TRUE);
if (error)
@@ -425,7 +425,6 @@ bst_file_dialog_open_project (BstFileDialog *self,
gxk_status_window_pop ();
gxk_idle_show_widget (GTK_WIDGET (app));
}
- bse_item_unuse (project.proxy_id());
return TRUE;
}
diff --git a/beast-gtk/bstmain.cc b/beast-gtk/bstmain.cc
index 28c9103..2cfbc40 100644
--- a/beast-gtk/bstmain.cc
+++ b/beast-gtk/bstmain.cc
@@ -260,28 +260,24 @@ main (int argc,
}
else
{
- Bse::ProjectH project = bse_server.use_new_project ("Untitled.bse");
+ Bse::ProjectH project = bse_server.create_project ("Untitled.bse");
SfiProxy wrepo = bse_project_get_wave_repo (project.proxy_id());
BseErrorType error = bse_wave_repo_load_file (wrepo, argv[i]);
if (!error)
{
app = bst_app_new (project);
gxk_idle_show_widget (GTK_WIDGET (app));
- bse_item_unuse (project.proxy_id());
gtk_widget_hide (beast_splash);
}
else
- {
- bse_item_unuse (project.proxy_id());
- sfi_error (_("Failed to load wave file \"%s\": %s"), argv[i], bse_error_blurb (error));
- }
+ sfi_error (_("Failed to load wave file \"%s\": %s"), argv[i], bse_error_blurb (error));
}
continue;
}
// load/merge projects
if (!app || !merge_with_last)
{
- Bse::ProjectH project = bse_server.use_new_project (argv[i]);
+ Bse::ProjectH project = bse_server.create_project (argv[i]);
BseErrorType error = bst_project_restore_from_file (project, argv[i], TRUE, TRUE);
if (rewrite_bse_file)
{
@@ -306,7 +302,6 @@ main (int argc,
gxk_idle_show_widget (GTK_WIDGET (app));
gtk_widget_hide (beast_splash);
}
- bse_item_unuse (project.proxy_id());
if (error)
sfi_error (_("Failed to load project \"%s\": %s"), argv[i], bse_error_blurb (error));
}
@@ -322,11 +317,9 @@ main (int argc,
*/
if (!app)
{
- Bse::ProjectH project = bse_server.use_new_project ("Untitled.bse");
-
+ Bse::ProjectH project = bse_server.create_project ("Untitled.bse");
bse_project_get_wave_repo (project.proxy_id());
app = bst_app_new (project);
- bse_item_unuse (project.proxy_id());
gxk_idle_show_widget (GTK_WIDGET (app));
gtk_widget_hide (beast_splash);
}
diff --git a/beast-gtk/bstplayback.cc b/beast-gtk/bstplayback.cc
index 808e6ac..4c0379f 100644
--- a/beast-gtk/bstplayback.cc
+++ b/beast-gtk/bstplayback.cc
@@ -18,7 +18,7 @@ bst_play_back_handle_new (void)
{
BstPlayBackHandle *handle = new BstPlayBackHandle();
- handle->project = bse_server.use_new_project ("# BEAST Play Back");
+ handle->project = bse_server.create_project ("# BEAST Play Back");
if (BST_DBG_EXT)
gxk_idle_show_widget (GTK_WIDGET (bst_app_new (handle->project)));
@@ -183,7 +183,5 @@ bst_play_back_handle_destroy (BstPlayBackHandle *handle)
if (handle->pcm_timeout)
g_source_remove (handle->pcm_timeout);
-
- bse_item_unuse (handle->project.proxy_id());
delete handle;
}
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 57bb11b..cbcac7a 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -189,7 +189,7 @@ interface Server : Object {
int32 n_scripts(); ///< Return the number of scripts currently running on this
server.
bool can_load (String file_name); ///< Check whether a loader can be found for a wave file.
void start_recording (String wave_file, float64 n_seconds); ///< Start recording to a WAV file.
- Project use_new_project (String project_name); ///< Create a new project, owned by the caller (name
is modified to be unique if necessary.
+ Project create_project (String project_name); ///< Create a new project (name is modified to be
unique if necessary.
};
} // Bse
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index 589684b..a24c845 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -366,32 +366,6 @@ bse_server_get (void)
return server;
}
-static void
-destroy_project (BseProject *project,
- BseServer *server)
-{
- server->projects = g_list_remove (server->projects, project);
-}
-
-BseProject*
-bse_server_create_project (BseServer *server,
- const gchar *name)
-{
- BseProject *project;
-
- g_return_val_if_fail (BSE_IS_SERVER (server), NULL);
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (bse_server_find_project (server, name) == NULL, NULL);
-
- project = (BseProject*) bse_object_new (BSE_TYPE_PROJECT, "uname", name, NULL);
- server->projects = g_list_prepend (server->projects, project);
- g_object_connect (project,
- "signal::release", destroy_project, server,
- NULL);
-
- return project;
-}
-
BseProject*
bse_server_find_project (BseServer *server,
const gchar *name)
@@ -1460,8 +1434,15 @@ ServerImpl::can_load (const String &file_name)
return finfo != NULL;
}
+static void
+destroy_project (BseProject *project, BseServer *server)
+{
+ server->projects = g_list_remove (server->projects, project);
+ bse_item_unuse (project);
+}
+
ProjectIfaceP
-ServerImpl::use_new_project (const String &project_name)
+ServerImpl::create_project (const String &project_name)
{
BseServer *server = as<BseServer*>();
/* enforce unique name */
@@ -1473,10 +1454,14 @@ ServerImpl::use_new_project (const String &project_name)
uname = g_strdup_format ("%s-%u", project_name.c_str(), num++);
}
/* create project */
- BseProject *project = bse_server_create_project (server, uname);
- g_free (uname);
- bse_item_use (BSE_ITEM (project));
+ BseProject *project = (BseProject*) bse_object_new (BSE_TYPE_PROJECT, "uname", uname, NULL);
+ bse_item_use (project);
+ server->projects = g_list_prepend (server->projects, project);
g_object_unref (project);
+ g_free (uname);
+ g_object_connect (project,
+ "signal::release", destroy_project, server,
+ NULL);
return shared_ptr_cast<ProjectIface> (project->as<ProjectIface*>());
}
diff --git a/bse/bseserver.hh b/bse/bseserver.hh
index a57e1f7..37860f7 100644
--- a/bse/bseserver.hh
+++ b/bse/bseserver.hh
@@ -36,8 +36,6 @@ struct BseServerClass : BseContainerClass
{};
BseServer* bse_server_get (void);
-BseProject* bse_server_create_project (BseServer *server,
- const gchar *name);
BseProject* bse_server_find_project (BseServer *server,
const gchar *name);
void bse_server_stop_recording (BseServer *server);
@@ -127,7 +125,7 @@ public:
virtual bool preferences_locked () override;
virtual int n_scripts () override;
virtual bool can_load (const String &file_name) override;
- virtual ProjectIfaceP use_new_project (const String &project_name) override;
+ virtual ProjectIfaceP create_project (const String &project_name) override;
void send_user_message (const UserMessage &umsg);
static ServerImpl& instance ();
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]