Click here to Skip to main content
16,008,010 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralEndDialog() for modal Pin
ns20-Mar-03 9:09
ns20-Mar-03 9:09 
GeneralRe: EndDialog() for modal Pin
Alvaro Mendez20-Mar-03 9:31
Alvaro Mendez20-Mar-03 9:31 
GeneralRe: EndDialog() for modal Pin
ns20-Mar-03 9:34
ns20-Mar-03 9:34 
GeneralRe: EndDialog() for modal Pin
Neville Franks20-Mar-03 9:37
Neville Franks20-Mar-03 9:37 
Generalsorry for the confusion Pin
ns20-Mar-03 9:42
ns20-Mar-03 9:42 
QuestionHow to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 7:43
professionalJoan M20-Mar-03 7:43 
AnswerRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 8:19
Stephane Rodriguez.20-Mar-03 8:19 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 8:44
professionalJoan M20-Mar-03 8:44 
Well, I've changed the code as you've suggested, but the handle leaks are even faster than before... (I'm sure that it is my fault because it's the first time that I use this kind of pointers and that I work with HTMLViews...). This is the code:
CComQIPtr<IHTMLDocument2> pHtmlDoc(this->GetHtmlDocument());

	if (pHtmlDoc)
	{
		pSafeArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
		
		if (pSafeArray)
		{ 
			hr = ::SafeArrayAccessData(pSafeArray,(LPVOID*) &pElement);
		
			if (!SUCCEEDED(hr))
			{
				bRetorn = false;
			}
			else
			{
				pElement->vt				= VT_BSTR;
				pElement->bstrVal		= csHTML.AllocSysString();

				hr = SafeArrayUnaccessData(pSafeArray);

				if (!SUCCEEDED(hr))
				{
					bRetorn = false;
				}
				else
				{
					pHtmlDoc->clear();
					pHtmlDoc->close();

					hr = pHtmlDoc->write(pSafeArray);
					
					if (!SUCCEEDED(hr))
					{
						bRetorn = false;
					}
				}

				SysFreeString(pElement->bstrVal);
			}

			if (pSafeArray) SafeArrayDestroy(pSafeArray);
		}

		pHtmlDoc->close();
	}


In the other hand, and using the first code (the posted in the first question) I've changed two things (and this is how the code is working now):
lpDispatch = this->GetHtmlDocument();

if (lpDispatch)
{
    hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDoc2);

    if (!SUCCEEDED(hr))
    {
        bRetorn = false;
    }
    else
    {
        pSafeArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);

        if (pSafeArray)
        {
            hr = ::SafeArrayAccessData(pSafeArray,(LPVOID*) &pElement);

            if (!SUCCEEDED(hr))
            {
                bRetorn = false;
            }
            else
            {
                pElement->vt             = VT_BSTR;
                pElement->bstrVal        = csHTML.AllocSysString();

                hr = SafeArrayUnaccessData(pSafeArray);

                if (!SUCCEEDED(hr))
                {
                    bRetorn = false;
                }
                else
                {
                    pHTMLDoc2->clear();
                    pHTMLDoc2->close();

                    hr = pHTMLDoc2->write(pSafeArray);

                    if (!SUCCEEDED(hr))
                    {
                        bRetorn = false;
                    }
                }

                SysFreeString(pElement->bstrVal);
            }

            if (pSafeArray) SafeArrayDestroy(pSafeArray);
        }

        if (pHTMLDoc2) pHTMLDoc2->close();
    }

    pHTMLDoc2->Release(); <code>this is new...</code>
    lpDispatch->Release(); <code>this is what I've moved...</code>
}
Using this version the problems are exactly the same than the ones that I've found in the first release...

Could you give me an idea on how to continue working? my customer has already seen the program and this program has to work 24 hours a day, this means that I cannot go back to plain texts and that I must find the solution...

Thanks a lot in advance...
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 9:19
Stephane Rodriguez.20-Mar-03 9:19 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 20:35
professionalJoan M20-Mar-03 20:35 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 21:17
Stephane Rodriguez.20-Mar-03 21:17 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 22:09
professionalJoan M20-Mar-03 22:09 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Stephane Rodriguez.20-Mar-03 22:31
Stephane Rodriguez.20-Mar-03 22:31 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 22:53
professionalJoan M20-Mar-03 22:53 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 22:59
professionalJoan M20-Mar-03 22:59 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M21-Mar-03 4:05
professionalJoan M21-Mar-03 4:05 
AnswerRe: How to avoid this? (HTMLView and Handle leaks) Pin
Neville Franks20-Mar-03 9:34
Neville Franks20-Mar-03 9:34 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M20-Mar-03 19:45
professionalJoan M20-Mar-03 19:45 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Neville Franks21-Mar-03 0:29
Neville Franks21-Mar-03 0:29 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M21-Mar-03 1:15
professionalJoan M21-Mar-03 1:15 
GeneralRe: How to avoid this? (HTMLView and Handle leaks) Pin
Joan M21-Mar-03 3:56
professionalJoan M21-Mar-03 3:56 
GeneralWenn printing the fill function doesn't work Pin
willempipi20-Mar-03 7:40
willempipi20-Mar-03 7:40 
GeneralRe: Wenn printing the fill function doesn't work Pin
Chris Losinger20-Mar-03 8:03
professionalChris Losinger20-Mar-03 8:03 
GeneralRe: Wenn printing the fill function doesn't work Pin
willempipi20-Mar-03 8:33
willempipi20-Mar-03 8:33 
Generalserialize Pin
dudic20-Mar-03 7:13
dudic20-Mar-03 7:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.