X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b21624e7e0b39e4cb640d48b54b3c535f2ad8625..0c55409f3a315e45963bc48f52435245e6af6c9d:/src/generic/prop.cpp diff --git a/src/generic/prop.cpp b/src/generic/prop.cpp index 00e5364606..7175580382 100644 --- a/src/generic/prop.cpp +++ b/src/generic/prop.cpp @@ -47,6 +47,7 @@ wxPropertyValue::wxPropertyValue(void) wxPropertyValue::wxPropertyValue(const wxPropertyValue& copyFrom) { + m_value.string = (wxChar*) NULL; m_modifiedFlag = FALSE; Copy((wxPropertyValue& )copyFrom); } @@ -178,7 +179,7 @@ wxPropertyValue::wxPropertyValue(wxStringList *the_list) wxNode *node = the_list->First(); while (node) { - char *s = (char *)node->Data(); + wxChar *s = (wxChar *)node->Data(); Append(new wxPropertyValue(s)); node = node->Next(); } @@ -242,7 +243,7 @@ void wxPropertyValue::Insert(wxPropertyValue *expr) void wxPropertyValue::Delete(wxPropertyValue *node) { wxPropertyValue *expr = GetFirst(); - + wxPropertyValue *previous = NULL; while (expr && (expr != node)) { @@ -254,7 +255,7 @@ void wxPropertyValue::Delete(wxPropertyValue *node) { if (previous) previous->m_next = expr->m_next; - + // If node was the first in the list, // make the list point to the NEXT one. if (GetFirst() == expr) @@ -327,10 +328,8 @@ wxPropertyValue *wxPropertyValue::NewCopy(void) const case wxPropertyValueStringPtr: return new wxPropertyValue(m_value.stringPtr); - case wxPropertyValueNull: -#ifdef __X__ - cerr << "Should never get here!\n"; -#endif + case wxPropertyValueNull: + wxFAIL_MSG( wxT("Should never get here!\n" ) ); break; } return NULL; @@ -338,6 +337,11 @@ wxPropertyValue *wxPropertyValue::NewCopy(void) const void wxPropertyValue::Copy(wxPropertyValue& copyFrom) { + if (m_type == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } m_type = copyFrom.Type(); switch (m_type) @@ -349,11 +353,11 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) case wxPropertyValueReal: (*this) = copyFrom.RealValue(); return ; - + case wxPropertyValueString: (*this) = wxString(copyFrom.StringValue()); return ; - + case wxPropertyValuebool: (*this) = copyFrom.BoolValue(); return ; @@ -371,10 +375,21 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) case wxPropertyValueStringPtr: { wxChar** s = copyFrom.StringValuePtr(); + +#if 0 + // what is this? are you trying to assign a bool or a string? VA can't figure it out.. +#if defined(__VISAGECPP__) || defined( __VISUALC__ ) + (*this) = s; +#else (*this) = s != 0; +#endif +#endif // if 0 + + (*this) = (bool)(s != 0); + return ; } - + case wxPropertyValueList: { m_value.first = NULL; @@ -389,10 +404,8 @@ void wxPropertyValue::Copy(wxPropertyValue& copyFrom) } return; } - case wxPropertyValueNull: -#ifdef __X__ - cerr << "Should never get here!\n"; -#endif + case wxPropertyValueNull: + wxFAIL_MSG( wxT("Should never get here!\n" ) ); break; } } @@ -454,20 +467,20 @@ void wxPropertyValue::WritePropertyClause(wxString& stream) // Write this expre if (node) { node->WritePropertyType(stream); - stream.Append( _T("(") ); + stream.Append( wxT("(") ); node = node->m_next; bool first = TRUE; while (node) { if (!first) - stream.Append( _T(" ") ); + stream.Append( wxT(" ") ); node->WritePropertyType(stream); node = node->m_next; - if (node) - stream.Append( _T(",\n" ) ); + if (node) + stream.Append( wxT(",\n" ) ); first = FALSE; } - stream.Append( _T(").\n\n") ); + stream.Append( wxT(").\n\n") ); } } @@ -478,43 +491,43 @@ void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any oth { case wxPropertyValueInteger: { - tmp.Printf( _T("%ld"), m_value.integer ); + tmp.Printf( wxT("%ld"), m_value.integer ); stream.Append( tmp ); break; } case wxPropertyValueIntegerPtr: { - tmp.Printf( _T("%ld"), *m_value.integerPtr ); + tmp.Printf( wxT("%ld"), *m_value.integerPtr ); stream.Append( tmp ); break; } case wxPropertyValuebool: { if (m_value.integer) - stream.Append( _T("True") ); + stream.Append( wxT("True") ); else - stream.Append( _T("False") ); + stream.Append( wxT("False") ); break; } case wxPropertyValueboolPtr: { if (*m_value.integerPtr) - stream.Append( _T("True") ); + stream.Append( wxT("True") ); else - stream.Append( _T("False") ); + stream.Append( wxT("False") ); break; } case wxPropertyValueReal: { double d = m_value.real; - tmp.Printf( _T("%.6g"), d ); + tmp.Printf( wxT("%.6g"), d ); stream.Append( tmp ); break; } case wxPropertyValueRealPtr: { double d = *m_value.realPtr; - tmp.Printf( _T("%.6g"), d ); + tmp.Printf( wxT("%.6g"), d ); stream.Append( tmp ); break; } @@ -525,7 +538,7 @@ void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any oth } case wxPropertyValueStringPtr: { - wxFAIL_MSG( _T("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") ); + wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") ); /* int i; int len = strlen(*(m_value.stringPtr)); @@ -540,20 +553,20 @@ void wxPropertyValue::WritePropertyType(wxString& stream) // Write as any oth case wxPropertyValueList: { if (!m_value.first) - stream.Append( _T("[]") ); + stream.Append( wxT("[]") ); else { wxPropertyValue *expr = m_value.first; - stream.Append( _T("[") ); + stream.Append( wxT("[") ); while (expr) { expr->WritePropertyType(stream); expr = expr->m_next; - if (expr) - stream.Append( _T(", ") ); + if (expr) + stream.Append( wxT(", ") ); } - stream.Append( _T("]") ); + stream.Append( wxT("]") ); } break; } @@ -580,6 +593,14 @@ void wxPropertyValue::operator=(const wxString& val1) const wxChar *val = (const wxChar *)val1; m_modifiedFlag = TRUE; + + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + if (m_type == wxPropertyValueNull) m_type = wxPropertyValueString; @@ -592,14 +613,13 @@ void wxPropertyValue::operator=(const wxString& val1) } else if (m_type == wxPropertyValueStringPtr) { - if (*m_value.stringPtr) - delete[] *m_value.stringPtr; + wxFAIL_MSG( wxT("Shouldn't try to assign a wxString reference to a char* pointer.") ); if (val) *m_value.stringPtr = copystring(val); else *m_value.stringPtr = NULL; } - + m_clientData = NULL; m_next = NULL; m_last = NULL; @@ -608,6 +628,13 @@ void wxPropertyValue::operator=(const wxString& val1) void wxPropertyValue::operator=(const long val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; if (m_type == wxPropertyValueNull) m_type = wxPropertyValueInteger; @@ -627,6 +654,13 @@ void wxPropertyValue::operator=(const long val) void wxPropertyValue::operator=(const bool val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; if (m_type == wxPropertyValueNull) m_type = wxPropertyValuebool; @@ -642,6 +676,13 @@ void wxPropertyValue::operator=(const bool val) void wxPropertyValue::operator=(const float val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; if (m_type == wxPropertyValueNull) m_type = wxPropertyValueReal; @@ -661,6 +702,13 @@ void wxPropertyValue::operator=(const float val) void wxPropertyValue::operator=(const wxChar **val) { + wxPropertyValueType oldType = m_type; + if (oldType == wxPropertyValueString) + { + delete[] m_value.string ; + m_value.string = NULL; + } + m_modifiedFlag = TRUE; m_type = wxPropertyValueStringPtr; @@ -773,7 +821,7 @@ wxChar **wxPropertyValue::StringValuePtr(void) const /* * A property (name plus value) */ - + IMPLEMENT_DYNAMIC_CLASS(wxProperty, wxObject) wxProperty::wxProperty(void) @@ -863,7 +911,7 @@ void wxProperty::operator=(const wxPropertyValue& val) /* * Base property view class */ - + IMPLEMENT_DYNAMIC_CLASS(wxPropertyView, wxEvtHandler) wxPropertyView::wxPropertyView(long flags) @@ -887,7 +935,7 @@ wxPropertyValidator *wxPropertyView::FindPropertyValidator(wxProperty *property) { if (property->GetValidator()) return property->GetValidator(); - + wxNode *node = m_validatorRegistryList.First(); while (node) { @@ -964,8 +1012,8 @@ void wxPropertySheet::RemoveProperty(const wxString& name) } bool wxPropertySheet::HasProperty(const wxString& name) const -{ - return (GetProperty(name)?TRUE:FALSE); +{ + return (GetProperty(name)?TRUE:FALSE); } // Clear all properties @@ -991,7 +1039,7 @@ void wxPropertySheet::SetAllModified(bool flag) wxProperty *prop = (wxProperty *)node->Data(); prop->GetValue().SetModified(flag); node = node->Next(); - } + } } /* @@ -1090,13 +1138,13 @@ bool wxPropertyValidator::StringToLong (wxChar *s, long *number) { wxChar *wxPropertyValidator::FloatToString (float number) { static wxChar buf[20]; - wxSprintf (buf, _T("%.6g"), number); + wxSprintf (buf, wxT("%.6g"), number); return buf; } wxChar *wxPropertyValidator::DoubleToString (double number) { static wxChar buf[20]; - wxSprintf (buf, _T("%.6g"), number); + wxSprintf (buf, wxT("%.6g"), number); return buf; }