[chronojump] Fixed _copy and behaviour of encoder configurations Now only one unnamed (last one) https://gitlab.g
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed _copy and behaviour of encoder configurations Now only one unnamed (last one) https://gitlab.g
- Date: Wed, 27 Apr 2022 09:26:38 +0000 (UTC)
commit 96cb48580d08269a67a4a334c44982297f007c40
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 27 11:25:17 2022 +0200
Fixed _copy and behaviour of encoder configurations
Now only one unnamed (last one)
https://gitlab.gnome.org/GNOME/chronojump/-/issues/96
src/gui/app1/encoder.cs | 32 +++++++++++++++++++++++++++++-
src/sqlite/encoderConfiguration.cs | 40 ++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletion(-)
---
diff --git a/src/gui/app1/encoder.cs b/src/gui/app1/encoder.cs
index ab5a8c387..81b327188 100644
--- a/src/gui/app1/encoder.cs
+++ b/src/gui/app1/encoder.cs
@@ -1858,6 +1858,11 @@ public partial class ChronoJumpWindow
//if user has deleted this econfSO, create it again
if(econfSO.uniqueID == -1)
{
+ /*
+ old (before Chronojump 2.2.2): create a Unnamed and if exists, a
Unnamed_copy, _copy2, ...
+ problem is when we import a lot of sessions, each time we load a
set with a config that we don't have in the database,
+ it creates a new config, all named Unnamed_copy* and it's a mess
+
string name =
SqliteEncoderConfiguration.IfNameExistsAddSuffix(Catalog.GetString("Unnamed"), "_" +
Catalog.GetString("copy"));
econfSO = new EncoderConfigurationSQLObject(
@@ -1869,8 +1874,33 @@ public partial class ChronoJumpWindow
"" //description
);
SqliteEncoderConfiguration.Insert(false, econfSO);
+ */
+ /*
+ new (at Chronojump 2.2.2):
+ Only one Unnamed.
+ - If it exists, delete it. Then create with new configuration
(could update but delete and insert seems safer because there are more params)
+ - If it does not exist the Unnamed, create it
+ If user renames it, then an Unnamed will be created next time that
a set with new different config is loaded
+ See: https://gitlab.gnome.org/GNOME/chronojump/-/issues/96
+ */
+ string unnamedTrans = Catalog.GetString("Unnamed");
+ EncoderConfigurationSQLObject econfSOUnnamed =
+ SqliteEncoderConfiguration.SelectByEncoderGIAndName(false,
currentEncoderGI, unnamedTrans);
+
+ if(econfSOUnnamed.uniqueID >= 0) // if exists, delete it
+ SqliteEncoderConfiguration.Delete (false, currentEncoderGI,
unnamedTrans);
+
+ econfSO = new EncoderConfigurationSQLObject(
+ -1, //uniqueID
+ currentEncoderGI, //encoderGI
+ true, //active
+ unnamedTrans, //name
+ eSQL.encoderConfiguration, //encoderConfiguration
+ "" //description
+ );
+ SqliteEncoderConfiguration.Insert(false, econfSO);
} else {
- //if exists on datbase mark and update sql row as active
+ //if exists on database mark and update sql row as active
econfSO.active = true;
SqliteEncoderConfiguration.Update(false, currentEncoderGI,
econfSO.name, econfSO);
}
diff --git a/src/sqlite/encoderConfiguration.cs b/src/sqlite/encoderConfiguration.cs
index 4f76a3317..e9d92f963 100644
--- a/src/sqlite/encoderConfiguration.cs
+++ b/src/sqlite/encoderConfiguration.cs
@@ -349,4 +349,44 @@ class SqliteEncoderConfiguration : Sqlite
return econfSO;
}
+
+ public static EncoderConfigurationSQLObject SelectByEncoderGIAndName (bool dbconOpened,
Constants.EncoderGI encoderGI, string name)
+ {
+ openIfNeeded(dbconOpened);
+
+ LogB.Information("SelectByEncoderGIAndName");
+ dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderConfigurationTable +
+ " WHERE encoderGI = \"" + encoderGI.ToString() + "\"" +
+ " AND name = \'" + name + "\'";
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject();
+
+ if(reader.Read())
+ {
+ string [] strFull = reader[4].ToString().Split(new char[] {':'});
+ EncoderConfiguration econf = new EncoderConfiguration(
+ (Constants.EncoderConfigurationNames)
+ Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
+ econf.ReadParamsFromSQL(strFull);
+
+ econfSO = new EncoderConfigurationSQLObject(
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ encoderGI, //encoderGI
+ true, //active
+ reader[3].ToString(), //name
+ econf, //encoderConfiguration
+ reader[5].ToString() //description
+ );
+ LogB.Information("found: " + econfSO.ToString());
+ }
+ reader.Close();
+ closeIfNeeded(dbconOpened);
+
+ return econfSO;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]