此代码在Windows和Linux中完美运行,但在Android中不调用appCfg :: ~appCfg()。如何修改代码以在所有平台上自动销毁appCfg(在关闭程序中)?
的.cpp
private void ComboBoxCompaniesSelectionChanged(object sender, SelectionChangedEventArgs e)
{
Client client = e.AddedItems[0] as Client;
if (client != null)
{
TruckServiceClient tsc = null; // ...
List<Representative> representatives = GetRepByComp(tsc, client.Id.ToString());
comboBoxRepresentatives.ItemsSource = representatives;
}
}
答案 0 :(得分:-1)
所有代码都不合适,所以我在这里写下其余的代码
·H
class SingletonDestroyer
{
private:
appCfg* p_instance;
public:
~SingletonDestroyer();
void initialize( appCfg* p );
};
class appCfg : public QObject
{
private:
static appCfg* p_instance;
static SingletonDestroyer destroyer;
QSettings * pSetting;
protected:
appCfg();
appCfg( const appCfg& );
appCfg& operator=( appCfg& );
~appCfg();
friend class SingletonDestroyer;
public:
static appCfg& getInstance();
...
};