[chronojump] Fixed bug on deleting signals (found on a tablet)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed bug on deleting signals (found on a tablet)
- Date: Thu, 17 Sep 2015 11:49:27 +0000 (UTC)
commit bc2e4e053462579a3cf4117bf3b5e04c10cdf533
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Sep 17 13:48:48 2015 +0200
Fixed bug on deleting signals (found on a tablet)
src/gui/encoder.cs | 22 ++++++++++++++++++----
src/sqlite/encoder.cs | 3 +++
2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 2faa3c4..9cf4eba 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1094,18 +1094,32 @@ public partial class ChronoJumpWindow
void delete_encoder_curve(bool dbconOpened, int uniqueID) {
LogB.Information(uniqueID.ToString());
+ bool eSQLfound = true;
+
+ //EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(dbconOpened, uniqueID, 0, 0, -1, "",
EncoderSQL.Eccons.ALL, false, true)[0];
+ //WARNING because SqliteEncoder.Select may not return nothing, and then cannot be assigned to
eSQL
+ //do this:
+
+ EncoderSQL eSQL = new EncoderSQL();
+ try {
+ eSQL = (EncoderSQL) SqliteEncoder.Select(dbconOpened, uniqueID, 0, 0, -1, "",
EncoderSQL.Eccons.ALL, false, true)[0];
+ } catch {
+ eSQLfound = false;
+ LogB.Warning("Catched! seems it's already deleted");
+ }
- EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(dbconOpened, uniqueID, 0, 0, -1, "",
EncoderSQL.Eccons.ALL, false, true)[0];
//remove the file
- bool deletedOk = Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
+ if(eSQLfound)
+ Util.FileDelete(eSQL.GetFullURL(false)); //don't convertPathToR
Sqlite.Delete(dbconOpened, Constants.EncoderTable, Convert.ToInt32(uniqueID));
ArrayList escArray = SqliteEncoder.SelectSignalCurve(dbconOpened,
-1, Convert.ToInt32(uniqueID), //signal, curve
-1, -1); //msStart, msEnd
- SqliteEncoder.DeleteSignalCurveWithCurveID(dbconOpened,
- Convert.ToInt32(eSQL.uniqueID)); //delete by curveID on SignalCurve table
+ if(eSQLfound)
+ SqliteEncoder.DeleteSignalCurveWithCurveID(dbconOpened,
+ Convert.ToInt32(eSQL.uniqueID)); //delete by curveID on SignalCurve
table
//if deleted curve is from current signal, uncheck it in encoderCaptureCurves
if(escArray.Count > 0) {
EncoderSignalCurve esc = (EncoderSignalCurve) escArray[0];
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 79a100a..ad40601 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -189,6 +189,9 @@ class SqliteEncoder : Sqlite
//pass uniqueID value and then will return one record. do like this:
//EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, myUniqueID, 0, 0, 0, "",
EncoderSQL.Eccons.ALL, false, true)[0];
+
+ //WARNING because SqliteEncoder.Select may not return nothing, and then cannot be assigned to eSQL
+ //see: delete_encoder_curve(bool dbconOpened, int uniqueID)
//don't care for the 0, 0, 0 because selection will be based on the myUniqueID and only one row will
be returned
//or
//pass uniqueID==-1 and personID, sessionID, signalOrCurve values, and will return some records
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]