修复了单例的bug

Signed-off-by: facat@lab.com <facat@lab.com>
This commit is contained in:
facat@lab.com
2014-11-26 20:49:33 +08:00
parent 53416f8f33
commit 38025aa1fc
7 changed files with 52 additions and 10 deletions

View File

@@ -1,10 +1,13 @@
#include "nodetoterminal.h"
#include <iostream>
QHash<QString,QString> *NodeToTerminal::ht=NULL;
NodeToTerminal::NodeToTerminal()
{
if(!NodeToTerminal::ht)
{
// std::cout<<"create"<<std::endl;
NodeToTerminal::ht=new QHash<QString,QString>;
// std::cout<<this->value("").toStdString()<<std::endl;
}
}
@@ -20,14 +23,24 @@ bool NodeToTerminal::contains(const QString& key)
QString NodeToTerminal::value(const QString& key)
{
// if(NodeToTerminal::ht)
// {
// //return NodeToTerminal::ht->value(key);
// return "not null";
// }
// else
// {
// return "null";
// }
// return "";
return NodeToTerminal::ht->value(key);
}
NodeToTerminal::~NodeToTerminal()
{
if(NodeToTerminal::ht)
{
delete NodeToTerminal::ht;
NodeToTerminal::ht=NULL;
}
// if(NodeToTerminal::ht)
// {
// delete NodeToTerminal::ht;
// NodeToTerminal::ht=NULL;
// }
}