// This file is generated by kconfig_compiler_kf6 from kcfg_custombuildsystemconfig.kcfg.
// All changes you do to this file will be lost.

#include "kcfg_custombuildsystemconfig.h"

#include <qglobal.h>
#include <QFile>

#include <QDebug>

class CustomBuildSystemSettingsHelper
{
  public:
    CustomBuildSystemSettingsHelper() noexcept : q(nullptr) {}
    ~CustomBuildSystemSettingsHelper() noexcept { delete q; q = nullptr; }
    CustomBuildSystemSettingsHelper(const CustomBuildSystemSettingsHelper&) = delete;
    CustomBuildSystemSettingsHelper& operator=(const CustomBuildSystemSettingsHelper&) = delete;
    CustomBuildSystemSettings *q;
};
Q_GLOBAL_STATIC(CustomBuildSystemSettingsHelper, s_globalCustomBuildSystemSettings)
CustomBuildSystemSettings *CustomBuildSystemSettings::self()
{
  if (!s_globalCustomBuildSystemSettings()->q)
     qFatal("you need to call CustomBuildSystemSettings::instance before using");
  return s_globalCustomBuildSystemSettings()->q;
}

void CustomBuildSystemSettings::instance(const QString& cfgfilename)
{
  if (s_globalCustomBuildSystemSettings()->q) {
     qDebug() << "CustomBuildSystemSettings::instance called after the first use - ignoring";
     return;
  }
  new CustomBuildSystemSettings(KSharedConfig::openConfig(cfgfilename));
  s_globalCustomBuildSystemSettings()->q->read();
}

void CustomBuildSystemSettings::instance(KSharedConfig::Ptr config)
{
  if (s_globalCustomBuildSystemSettings()->q) {
     qDebug() << "CustomBuildSystemSettings::instance called after the first use - ignoring";
     return;
  }
  new CustomBuildSystemSettings(std::move(config));
  s_globalCustomBuildSystemSettings()->q->read();
}

CustomBuildSystemSettings::CustomBuildSystemSettings( KSharedConfig::Ptr config )
  : KDevelop::ProjectConfigSkeleton( std::move( config ) )
{
  Q_ASSERT(!s_globalCustomBuildSystemSettings()->q);
  s_globalCustomBuildSystemSettings()->q = this;
}

CustomBuildSystemSettings::~CustomBuildSystemSettings()
{
  if (s_globalCustomBuildSystemSettings.exists() && !s_globalCustomBuildSystemSettings.isDestroyed()) {
    s_globalCustomBuildSystemSettings()->q = nullptr;
  }
}

