mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Esc: Fixed crash on script error, Core: ValueMap - added String key variants, CtrlLib: ArrayCtrl - fixed issue with repeated SetCtrl for the same cell
git-svn-id: svn://ultimatepp.org/upp/trunk@1829 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1f04877186
commit
8293cc2216
4 changed files with 19 additions and 10 deletions
|
|
@ -694,8 +694,9 @@ public:
|
|||
void Clear();
|
||||
|
||||
void Add(const Value& key, const Value& value);
|
||||
void Add(const char *s, const Value& value) { Add(Value(s), value); }
|
||||
void Add(Id id, const Value& value) { Add(Value(id.ToString()), value); }
|
||||
void Add(const String& s, const Value& value) { Add(Value(s), value); }
|
||||
void Add(const char *s, const Value& value) { Add(Value(s), value); }
|
||||
void Add(Id id, const Value& value) { Add(Value(id.ToString()), value); }
|
||||
|
||||
const Index<Value>& GetKeys() const { return data->key; }
|
||||
ValueArray GetValues() const { return data->value; }
|
||||
|
|
@ -703,6 +704,7 @@ public:
|
|||
operator ValueArray() const { return GetValues(); }
|
||||
|
||||
Value operator[](const Value& k) const;
|
||||
Value operator[](const String& s) const { return operator[](Value(s)); }
|
||||
Value operator[](const char *s) const { return operator[](Value(s)); }
|
||||
Value operator[](const Id& k) const { return operator[](Value(k.ToString())); }
|
||||
|
||||
|
|
|
|||
|
|
@ -164,8 +164,19 @@ void ArrayCtrl::CellCtrl::LeftDown(Point, dword)
|
|||
ctrl->SetFocus();
|
||||
}
|
||||
|
||||
void ArrayCtrl::CellInfo::Free()
|
||||
{
|
||||
if(ptr.GetBit()) {
|
||||
CellCtrl *cc = (CellCtrl *)ptr.GetPtr();
|
||||
if(cc->owned)
|
||||
delete cc->ctrl;
|
||||
delete cc;
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayCtrl::CellInfo::Set(Ctrl *ctrl, bool owned, bool value)
|
||||
{
|
||||
Free();
|
||||
CellCtrl *cc = new CellCtrl;
|
||||
cc->ctrl = ctrl;
|
||||
cc->Add(*ctrl);
|
||||
|
|
@ -183,12 +194,7 @@ ArrayCtrl::CellInfo::CellInfo(pick_ CellInfo& s)
|
|||
|
||||
ArrayCtrl::CellInfo::~CellInfo()
|
||||
{
|
||||
if(ptr.GetBit()) {
|
||||
CellCtrl *cc = (CellCtrl *)ptr.GetPtr();
|
||||
if(cc->owned)
|
||||
delete cc->ctrl;
|
||||
delete cc;
|
||||
}
|
||||
Free();
|
||||
}
|
||||
|
||||
Ctrl& ArrayCtrl::SetCtrl(int i, int j, Ctrl *newctrl, bool owned, bool value)
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ private:
|
|||
struct CellInfo : Moveable<CellInfo> {
|
||||
BitAndPtr ptr;
|
||||
|
||||
void Free();
|
||||
void Set(Ctrl *ctrl, bool owned, bool value);
|
||||
bool IsCtrl() const { return ptr.GetBit(); }
|
||||
CellCtrl& GetCtrl() const { ASSERT(IsCtrl()); return *(CellCtrl *)ptr.GetPtr(); }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ EscValue Esc::Get(const SRVal& val)
|
|||
else
|
||||
if(v.IsArray()) {
|
||||
int count = v.GetCount();
|
||||
if(ss.IsArray()) {
|
||||
if(ss.IsArray() && ss.GetArray().GetCount() >= 2) {
|
||||
EscValue v1 = ss.ArrayGet(0);
|
||||
EscValue v2 = ss.ArrayGet(1);
|
||||
int i = v1.IsInt() ? v1.GetInt() : 0;
|
||||
|
|
@ -112,7 +112,7 @@ void Esc::Assign(EscValue& val, const Vector<EscValue>& sbs, int si, const EscVa
|
|||
else {
|
||||
int count = val.GetCount();
|
||||
if(ss.IsArray()) {
|
||||
if(!src.IsArray())
|
||||
if(!src.IsArray() || ss.GetArray().GetCount() < 2)
|
||||
ThrowError("only array can be assigned to the slice");
|
||||
EscValue v1 = ss.ArrayGet(0);
|
||||
EscValue v2 = ss.ArrayGet(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue