Geary.Db.Context: Remove separate logging_parent property
Since each context type already has access to the object that is its context parent, don't bother with a stand-alone `logging_parent` property, just have context types implement it and return the appropriate object.
This commit is contained in:
parent
0fa0d0ea4d
commit
940ca83195
5 changed files with 23 additions and 12 deletions
|
|
@ -33,8 +33,7 @@ public abstract class Geary.Db.Context : BaseObject, Logging.Source {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent { get { return _logging_parent; } }
|
||||
private weak Logging.Source? _logging_parent = null;
|
||||
public abstract Logging.Source? logging_parent { get; }
|
||||
|
||||
|
||||
internal virtual Database? get_database() {
|
||||
|
|
@ -53,11 +52,6 @@ public abstract class Geary.Db.Context : BaseObject, Logging.Source {
|
|||
return null;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void set_logging_parent(Logging.Source parent) {
|
||||
this._logging_parent = parent;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public abstract Logging.State to_logging_state();
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@ public class Geary.Db.DatabaseConnection : Context, Connection {
|
|||
public Database database { get { return this._database; } }
|
||||
private weak Database _database;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override Logging.Source? logging_parent {
|
||||
get { return this._database; }
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
internal Sqlite.Database db { get { return this._db; } }
|
||||
private Sqlite.Database _db;
|
||||
|
|
@ -119,7 +124,6 @@ public class Geary.Db.DatabaseConnection : Context, Connection {
|
|||
/** {@inheritDoc} */
|
||||
public Statement prepare(string sql) throws DatabaseError {
|
||||
var prepared = new Statement(this, sql);
|
||||
prepared.set_logging_parent(this);
|
||||
return prepared;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ public class Geary.Db.Database : Context {
|
|||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override Logging.Source? logging_parent { get { return _logging_parent; } }
|
||||
private weak Logging.Source? _logging_parent = null;
|
||||
|
||||
private DatabaseConnection? primary = null;
|
||||
private int outstanding_async_jobs = 0;
|
||||
private ThreadPool<TransactionAsyncJob>? thread_pool = null;
|
||||
|
|
@ -143,7 +147,6 @@ public class Geary.Db.Database : Context {
|
|||
var cx = new DatabaseConnection(
|
||||
this, Sqlite.OPEN_READWRITE, cancellable
|
||||
);
|
||||
cx.set_logging_parent(this);
|
||||
|
||||
try {
|
||||
// drop existing test table (in case created in prior failed open)
|
||||
|
|
@ -233,7 +236,6 @@ public class Geary.Db.Database : Context {
|
|||
DatabaseConnection cx = new DatabaseConnection(
|
||||
this, sqlite_flags, cancellable
|
||||
);
|
||||
cx.set_logging_parent(this);
|
||||
prepare_connection(cx);
|
||||
return cx;
|
||||
}
|
||||
|
|
@ -357,6 +359,10 @@ public class Geary.Db.Database : Context {
|
|||
return yield job.wait_for_completion_async();
|
||||
}
|
||||
|
||||
/** Sets the logging parent context object for this database. */
|
||||
public void set_logging_parent(Logging.Source parent) {
|
||||
this._logging_parent = parent;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override Logging.State to_logging_state() {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ public class Geary.Db.Result : Geary.Db.Context {
|
|||
|
||||
public Statement statement { get; private set; }
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override Logging.Source? logging_parent {
|
||||
get { return this.statement; }
|
||||
}
|
||||
|
||||
// This results in an automatic first next().
|
||||
internal Result(Statement statement, Cancellable? cancellable) throws Error {
|
||||
this.statement = statement;
|
||||
set_logging_parent(statement);
|
||||
|
||||
statement.was_reset.connect(on_query_finished);
|
||||
statement.bindings_cleared.connect(on_query_finished);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ public class Geary.Db.Statement : Context {
|
|||
|
||||
public string sql { get; private set; }
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override Logging.Source? logging_parent {
|
||||
get { return this.connection; }
|
||||
}
|
||||
|
||||
internal DatabaseConnection connection { get; private set; }
|
||||
|
||||
internal Sqlite.Statement stmt;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue