Patch #2976 2010-04-08 05:04
loaden
Fix (or Feature?) wxSmith's identifier handler- Download
- 2976-Fix_or_Feature.patch (3.5 KB)
Index: src/plugins/contrib/wxSmith/wxwidgets/wxscorrector.cpp
===================================================================
--- src/plugins/contrib/wxSmith/wxwidgets/wxscorrector.cpp (revision 6202)
+++ src/plugins/contrib/wxSmith/wxwidgets/wxscorrector.cpp (working copy)
@@ -27,6 +27,8 @@
#include "wxsitemresdata.h"
#include <logmanager.h>
+static const wxString s_IdPrefix = _T("ID_");
+
wxsCorrector::wxsCorrector(wxsItemResData* Data):
m_Data(Data),
m_NeedRebuild(true)
@@ -101,7 +103,10 @@
}
else
{
- m_Ids.insert(IdName);
+ if (!IsWxWidgetsIdPrefix(IdName))
+ {
+ m_Ids.insert(IdName);
+ }
}
}
@@ -138,7 +143,10 @@
{
Ret = true;
SetNewIdName(Item);
- m_Ids.insert(Item->GetIdName());
+ if (!IsWxWidgetsIdPrefix(Item->GetIdName()))
+ {
+ m_Ids.insert(Item->GetIdName());
+ }
}
}
@@ -188,13 +196,32 @@
Item->SetIdName(IdName);
}
- if ( m_Ids.empty() || (m_Ids.find(IdName) != m_Ids.end()) )
+ if ( m_Ids.find(IdName) != m_Ids.end() )
{
SetNewIdName(Item);
}
- m_Ids.insert(Item->GetIdName());
+
+ if (!IsWxWidgetsIdPrefix(Item->GetIdName()))
+ {
+ m_Ids.insert(Item->GetIdName());
+ }
}
+ if ( Item->GetPropertiesFlags() & flLocal )
+ {
+ wxString prefix = s_IdPrefix;
+ prefix << Item->GetInfo().DefaultVarName.Upper();
+ wxString curIdName = Item->GetIdName();
+ if (curIdName.StartsWith(prefix))
+ {
+ Item->SetIdName(_T("wxID_ANY"));
+ if (m_Ids.find(curIdName) != m_Ids.end())
+ {
+ m_Ids.erase(curIdName);
+ }
+ }
+ }
+
m_NeedRebuild = false;
}
@@ -223,8 +250,10 @@
if ( Item->GetPropertiesFlags() & flId )
{
- wxString Id = Item->GetIdName();
- m_Ids.insert(Id);
+ if (!IsWxWidgetsIdPrefix(Item->GetIdName()))
+ {
+ m_Ids.insert(Item->GetIdName());
+ }
}
}
@@ -252,7 +281,7 @@
void wxsCorrector::SetNewIdName(wxsItem* Item)
{
- wxString Prefix = _T("ID_");
+ wxString Prefix = s_IdPrefix;
Prefix << Item->GetInfo().DefaultVarName.Upper();
wxString NewName;
for ( int i=1;; i++ )
@@ -296,7 +325,10 @@
{
SetNewIdName(Item);
}
- m_Ids.insert(Item->GetIdName());
+ if (!IsWxWidgetsIdPrefix(Item->GetIdName()))
+ {
+ m_Ids.insert(Item->GetIdName());
+ }
}
wxsParent* Parent = Item->ConvertToParent();
@@ -384,6 +416,11 @@
return FixVarName(Id);
}
+bool wxsCorrector::IsWxWidgetsIdPrefix(const wxString& Id)
+{
+ return Id.StartsWith(_T("wxID_"));
+}
+
void wxsCorrector::ClearCache()
{
m_NeedRebuild = true;
Index: src/plugins/contrib/wxSmith/wxwidgets/wxscorrector.h
===================================================================
--- src/plugins/contrib/wxSmith/wxwidgets/wxscorrector.h (revision 6202)
+++ src/plugins/contrib/wxSmith/wxwidgets/wxscorrector.h (working copy)
@@ -91,6 +91,8 @@
/** \brief Function checking and fixing if necessary identifier */
bool FixIdName(wxString& Id);
+ bool IsWxWidgetsIdPrefix(const wxString& Id);
+
void RebuildSetsReq(wxsItem* Item,wxsItem* Exclude);
bool FixAfterLoadCheckNames(wxsItem* Item);
bool FillEmpty(wxsItem* Item);
History
loaden 2010-04-08 05:06