Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Map::Insert a COM Object question, about storing and releasing[Solved]


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Conny14156   Members   -  Reputation: 277

Like
0Likes
Like

Posted 18 February 2013 - 02:28 AM

Hi,

This may seems as a weird question but, is this the correct way to "Store" a ID3D11ShaderResourceView* Pointer?

Am trying to store COM Object pointer inside a simple map with a std::string key.

I get no error's but when I quit the program it complains about unreleased objects.

Neither do I get a error when I try to release the "objects".

So I start to question my method about how to release it.

The reason why I am using a while loop with .empty(); is cause I can't seems to use the [] operator except for [0]. while am at it would appreciate if someone could explain that to >.<

 

		
ID3D11ShaderResourceView* t;
std::map<std::string,ID3D11ShaderResourceView*> TotalTexture;
std::vector<std::string> TotalTextureToLoad;
TotalTexture.insert
(
TotalTexture.end(),std::pair<std::string,ID3D11ShaderResourceView*>(TotalTextureToLoad[i],t)

);
while(!TotalTexture.empty())
{
	TotalTexture.begin()->second->Release();
	TotalTexture.erase(TotalTexture.begin());
}

 

 

 

 

 

    


Sponsor:

#2 KnolanCross   Members   -  Reputation: 1732

Like
0Likes
Like

Posted 18 February 2013 - 10:39 AM

Have you checked the return of the method call, I have never used D3D, but in the reference manual it says it will print the reference count, so you can check if the problem is here or otherwhere.

 

To clean the map, I believe the code should be something like this:

 

for (std::map<std::string,ID3D11ShaderResourceView*>::iterator it = TotalTexture.begin(); it != TotalTexture.end(); ++it){
	it->second->Release();
}
TotalTexture.clear();

 

References I used are those two:

http://www.cplusplus.com/reference/map/map/begin/

http://www.cplusplus.com/reference/map/map/clear/


Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).


#3 Conny14156   Members   -  Reputation: 277

Like
0Likes
Like

Posted 18 February 2013 - 10:54 PM

Got it to work, The problem was that I Called the loadAll(), twice. and I was trying to insert the same key inside the map, so there were a certain numbers of objects that wasnt getting released, cause the pointer was not inside the map.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS