Sqlite: Fix double throwing for reset

We do want prevent throwing again for reset if we already have thrown an
exception but we want to throw if there was no exception.

Change-Id: Iaf9fffb872ccd579a8ccde02381b5e5d30d5c4cb
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-10-23 13:26:32 +02:00
parent e7e7ee057e
commit 9678c86e40
2 changed files with 48 additions and 2 deletions

View File

@@ -193,6 +193,8 @@ public:
while (BaseStatement::next())
emplaceBackValues<ResultTypeCount>(resultValues);
resetter.reset();
return resultValues;
}
@@ -210,6 +212,8 @@ public:
while (BaseStatement::next())
emplaceBackValues<ResultTypeCount>(resultValues);
resetter.reset();
return resultValues;
}
@@ -228,6 +232,8 @@ public:
while (BaseStatement::next())
emplaceBackValues<ResultTypeCount>(resultValues);
resetter.reset();
}
return resultValues;
@@ -249,6 +255,8 @@ public:
while (BaseStatement::next())
emplaceBackValues<ResultTypeCount>(resultValues);
resetter.reset();
}
return resultValues;
@@ -267,6 +275,8 @@ public:
if (BaseStatement::next())
resultValue = assignValue<Utils::optional<ResultType>, ResultTypeCount>();
resetter.reset();
return resultValue;
}
@@ -288,12 +298,29 @@ private:
: statement(statement)
{}
~Resetter()
void reset()
{
statement.reset();
try {
statement.reset();
} catch (...) {
shouldReset = false;
throw;
}
shouldReset = false;
}
~Resetter() noexcept
{
try {
if (shouldReset)
statement.reset();
} catch (...) {
}
}
StatementImplementation &statement;
bool shouldReset = true;
};
struct ValueGetter