|
I get an access violation when trying to add to a map in my release build. Since it works fine in debug, and if I turn off optimisations in release, I know its something I'm doing wrong. But I don't know what...
Interestingly (?), the code that fails is in a loop which works on the first iteration, and fails on the second, suggesting perhaps a problem with initialising (or reinitialising) something.
Any help or tips very much appreciated
The code that fails is (bold line):
ManInfo mi;
...
...
if (m_ManMap.count(lSubmainID) == 0)
{
mi.SubmainJunctionPt = m_pCADEngine->GetEntityPoint(pSubmainJnc->GetHandle(), 1);
mi.LatEndPt[0] = m_pCADEngine->GetEntityPoint(pFreeEnd->GetHandle(), 1);
mi.LatLen[0] = mi.SubmainJunctionPt.GetDistanceTo2D(mi.LatEndPt[0]);
mi.DistToRef = mi.SubmainJunctionPt.GetDistanceTo2D(m_ManRefPt);
m_ManMap[lSubmainID] = mi;
}
else
{
...
I have a structure thus:
struct ManInfo
{
Point3D SubmainJunctionPt;
Point3D LatEndPt[2];
double LatLen[2];
double DistToRef;
ManInfo()
{
SubmainJunctionPt.Construct(NO_ELEVATION, NO_ELEVATION, NO_ELEVATION);
LatEndPt[0].Construct(NO_ELEVATION, NO_ELEVATION, NO_ELEVATION);
LatEndPt[1].Construct(NO_ELEVATION, NO_ELEVATION, NO_ELEVATION);
LatLen[0] = -1.0L;
LatLen[1] = -1.0L;
DistToRef = -1.0L;
}
ManInfo& ManInfo::operator= (const ManInfo& second)
{
if (this != &second)
{
SubmainJunctionPt.Construct(second.SubmainJunctionPt);
LatEndPt[0].Construct(second.LatEndPt[0]);
LatEndPt[1].Construct(second.LatEndPt[1]);
LatLen[0] = second.LatLen[0];
LatLen[1] = second.LatLen[1];
DistToRef = second.DistToRef;
}
return *this;
}
};
And a map member variable thus:
typedef map<LONG, ManInfo> ManMap;
ManMap m_ManMap;
|
|
|
|
|
I don't know if it helps determine what the problem is, but I can fix it by disabling inline function expansion...
|
|
|
|
|
Given you've got an assignment operator, do you need a copy constructor as well? And a destructor?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Good suggestion Stuart, given that:
In C++, the implicitly declared assignment operator is a public and inline member function.
but it didn't help I'm afraid...
|
|
|
|
|
Well, reading around I see there are possible problems with static storage when using STL across DLLs and EXEs. My struct and map are defined and used in a DLL, but the class is dllexport ed to the EXE.
I've found that to make this work I have to turn off inlining in both the DLL and the EXE...so perhaps this is the issue??
|
|
|
|
|
That (very probably) explains it all if your C runtime is statically linked in the EXE or the DLL or both. If so, use a DLL runtime in DLL and EXE.
The reason this scenario ACCVIOs is that the DLL and EXE are using different heaps, whereas if they're using a DLL runtime, they use the same one.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for looking at this Stuart, but still no joy. Both my EXE and DLL link the MT DLL runtime - unless its the multithreaded version that causes the problem... either way, since I need to make progress here, I switched out the std::map for a CMap and I'm golden
|
|
|
|
|
I don't have time to figure out why this doesn't work, so I just changed it to CMap instead!
|
|
|
|
|
Damn - I hate not being able to crush a bug
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm having the same problem. Are you inheriting from CObject and passing an instance to your View(s) via UpdateAllViews( , , instance )?
|
|
|
|
|
I have derived from the interface(IPimSrcContactNew),but the system did not invoke this API(IPimSrcContactNew::Create)?
Please help me. Thanks.
|
|
|
|
|
You need to do more than just inherit from it - it has to be a proper COM object.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Could you tell me in detail. thanks.
|
|
|
|
|
Not really - there's more to COM than I can tell you - you're going to have to learn about the technology underpinning your task.
Look for some COM/ATL tutorials like this one[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
list<int> l1,l2;
...
find(l1.begin(), l2.end(), 1)</int>
This code compiles, so I think it is better to use following symantic:
find(l1, IndexBegin, count, 1);
It is more consistent, isn't it?
|
|
|
|
|
Iterators are a great way to traverse a list.
This makes the find algorithm to be used with any sort of container that implements iterators.
This way STL is able to have one single find algorithm that works with several different containers.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
followait wrote: It is more consistent, isn't it?
No. Who says you have to have a container? Who says you have identifiable indices and counts? What about when you want to iterate from end to beginning of a container rather than beginning to end?
Using iterators allows you to do some very neat things with iterator adaptors[^] and still be able to use standard algorithms.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Itearators are (roughly speaking) a generalization of indexes, just like, for instance, a vector is a generalization of a standard array. If you find useful vectors then, one day, you'll probably find useful iterators too.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
While navigating (with the wtl 8 tabbed browser sample) I often get script
errors on different pages and the scripts are not executed (the same problem
does not appear in standard internet explorer)
Tryed this solution:
http://kbalertz.com/261003/Handle-Script-Errors-WebBrowser-Control.aspx
but the Exec method of IOLECommand interface seems to get never executed
(note that Disable Script Debugging option is set as required)
also tryed this other solution:
http://support.microsoft.com/kb/317024
that seems to disable the errors in very few cases but the script are never executed.
Hope someone knows the point.
Thanks as usual.
M.
|
|
|
|
|
|
I program an appwizard for VC6 recently,and want to create a project( using the appwizard) which has the follwoing name of a project's configuations,for example,
project's configuations:
default: new:
win32 Debug ===> Checked
win32 Release ===> Free
thanks!
|
|
|
|
|
I want to write an AppWizard for vc6,but I don't know how to get a project's active configuration.
(I am newbie in ATL)
could someone give me a hand?
void CWinDriverAppWiz::CustomizeProject(IBuildProject* pProject)
...
IApplication *pApp;
CComBSTR projname;
CComPtr<idispatch> iDisp=NULL;
...
pApp->get_ActiveConfiguration(&iDisp);
CComQIPtr<igenericproject,&iid_igenericproject> pActiveConf(iDisp);
iDisp=NULL;
pActiveConf->get_Name(&projname);
}
modified on Thursday, February 19, 2009 5:51 AM
|
|
|
|
|
This worked for me with an add-in I wrote (note - m_piApplication , declared with type CComPtr<IApplication> is the IApplication pointer:
CComPtr<IDispatch> actCfgDisp;
if (FAILED(m_piApplication->get_ActiveConfiguration(&actCfgDisp)) || !actCfgDisp) return E_FAIL;
CComQIPtr<IConfiguration> activeConfiguration(actCfgDisp);
if (!activeConfiguration) return E_FAIL;
CComBSTR configurationName;
CString configuration;
if (SUCCEEDED(activeConfiguration->get_Name(&configurationName)))
{
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I don't know how to initialize "m_piApplication"(IApplication* m_piApplication) by pProject(IBuildProject* pProject).
The problem puzzles me so long time1
|
|
|
|
|
You can't get m_piApplication from an IBuildProject.
Instead, you need to remember it from when VisualStudio calls the OnConnection method of your add-in object (that's the one that implements IDSAddIn).
I found this article[^] very useful when implementing my add-in.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|