Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into 'master'
Reformat code to common style and fix some small issues

See individual commits

@Sage @rainemak

See merge request !6
  • Loading branch information
pvuorela committed Oct 11, 2016
2 parents a470b9b + 3321d4a commit 55f003e
Show file tree
Hide file tree
Showing 73 changed files with 633 additions and 342 deletions.
Whitespace-only changes.
33 changes: 22 additions & 11 deletions libssu/sandbox.cpp
Expand Up @@ -58,19 +58,22 @@ Sandbox *Sandbox::s_activeInstance = 0;
Sandbox::Sandbox()
: m_defaultConstructed(true), m_usage(UseDirectly), m_scopes(ThisProcess),
m_sandboxPath(QProcessEnvironment::systemEnvironment().value("SSU_SANDBOX_DIR")),
m_prepared(false){
m_prepared(false)
{
if (!activate()) {
qFatal("%s: Failed to activate", Q_FUNC_INFO);
}
}

Sandbox::Sandbox(const QString &sandboxPath, Usage usage, Scopes scopes)
: m_defaultConstructed(false), m_usage(usage), m_scopes(scopes),
m_sandboxPath(sandboxPath), m_prepared(false){
m_sandboxPath(sandboxPath), m_prepared(false)
{
Q_ASSERT(!sandboxPath.isEmpty());
}

Sandbox::~Sandbox(){
Sandbox::~Sandbox()
{
if (isActive()) {
deactivate();
}
Expand All @@ -82,11 +85,13 @@ Sandbox::~Sandbox(){
}
}

bool Sandbox::isActive() const{
bool Sandbox::isActive() const
{
return s_activeInstance == this;
}

bool Sandbox::activate(){
bool Sandbox::activate()
{
Q_ASSERT_X(s_activeInstance == 0, Q_FUNC_INFO, "Only one instance can be active!");

if (!prepare()) {
Expand All @@ -101,7 +106,8 @@ bool Sandbox::activate(){
return true;
}

void Sandbox::deactivate(){
void Sandbox::deactivate()
{
Q_ASSERT(isActive());

if (m_scopes & ChildProcesses) {
Expand Down Expand Up @@ -138,7 +144,8 @@ QString Sandbox::map(const QString &pathName, const QString &fileName)
* @c QDir::NoDotAndDotDot is always added into @a filters.
*/
bool Sandbox::addWorldFiles(const QString &directory, QDir::Filters filters,
const QStringList &filterNames, bool recurse){
const QStringList &filterNames, bool recurse)
{
Q_ASSERT(!isActive());
Q_ASSERT(!directory.isEmpty());

Expand Down Expand Up @@ -217,12 +224,14 @@ bool Sandbox::addWorldFiles(const QString &directory, QDir::Filters filters,
return true;
}

bool Sandbox::addWorldFile(const QString &file){
bool Sandbox::addWorldFile(const QString &file)
{
return addWorldFiles(QFileInfo(file).path(), QDir::NoFilter,
QStringList() << QFileInfo(file).fileName());
}

bool Sandbox::prepare(){
bool Sandbox::prepare()
{
Q_ASSERT(m_defaultConstructed || !m_sandboxPath.isEmpty());

if (m_prepared) {
Expand Down Expand Up @@ -265,7 +274,8 @@ bool Sandbox::prepare(){
return true;
}

QString Sandbox::createTmpDir(const QString &nameTemplate){
QString Sandbox::createTmpDir(const QString &nameTemplate)
{
static const int REASONABLE_REPEAT_COUNT = 10;

for (int i = 0; i < REASONABLE_REPEAT_COUNT; ++i) {
Expand All @@ -284,7 +294,8 @@ QString Sandbox::createTmpDir(const QString &nameTemplate){
return QString();
}

bool Sandbox::copyDir(const QString &directory, const QString &newName){
bool Sandbox::copyDir(const QString &directory, const QString &newName)
{
const QDir sourceRoot(directory);
const QDir destinationRoot(newName);

Expand Down
3 changes: 2 additions & 1 deletion libssu/sandbox_p.h
Expand Up @@ -18,7 +18,8 @@
getenv("SSU_TESTS_DATA_PATH") : \
TESTS_DATA_PATH)

class Sandbox {
class Sandbox
{
public:
enum Usage {
UseDirectly,
Expand Down

0 comments on commit 55f003e

Please sign in to comment.