|
Thanks CPallini,
Cool! I think your option is you agree with my option 2. Then another question, suppose my component implements interface IX and IY, and both IX and IY will implement IUnknown, so will there be diamond problem?
regards,
George
|
|
|
|
|
George_George wrote: I think your option is you agree with my option 2.
Yes.
George_George wrote: Then another question, suppose my component implements interface IX and IY, and both IX and IY will implement IUnknown, so will there be diamond problem?
Nope (a coclass is not a C++ class).
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]
|
|
|
|
|
Thanks CPallini,
I think for the diamond issue I mentioned, you mean writing some code like this in my sample? The normal solution is providing one common implementation of AddRef/Release/QueryInterface in CFoo, so there is no diamond problem?
CFoo:IX, IY {
IX:IUnknown{}
IY:IUnknown{}
IUnknown{}
regards,
George
|
|
|
|
|
|
Thanks Hamid,
Looks like different from what CPallini said -- CPallini said every interface must implement IUnknown, but the wiki page mentioned every component must implement IUnknown -- "COM objects must minimally implement this interface"? I am confused.
Could you clarify please?
regards,
George
|
|
|
|
|
I think here[^] and here[^] are good articles for you.
|
|
|
|
|
Thanks Hamid,
What is your conclusion of my orignial question? You agree with my point 1 of point 2?
regards,
George
|
|
|
|
|
I have some memory leak in my code.
In my application i have some method that called every 5 seconds - and i found that my memory leak is in this method.
The leak increase the memory for 4kb every 5-10 seconds.
Attached the part of the code that i found that causing the memory leak.
void foo(const VARIANT FAR& Var1, const VARIANT FAR& Var2, const VARIANT FAR& Var3)
{
COleSafeArray SafeV1, SafeV2, SafeV3;
SafeV1 = Var1;
SafeV2 = Var2;
SafeV3 = Var3;
int iNumObjs = SafeV1.GetOneDimSize();
COleVariant vV1, vV2, vV3;
for ( long i = 0 ; i < iNumObjs ; i++ )
{
CString TempV1,Value;
SafeV1.GetElement(&i, &vV1);
TempV1 = vV1.bstrVal;
SafeV2.GetElement(&i, &vV2);
SafeV3.GetElement(&i, &vV3);
Value = vV3.bstrVal;
}
}
|
|
|
|
|
Try to change from:
COleVariant vV1, vV2, vV3;
for ( long i = 0 ; i < iNumObjs ; i++ )
{
CString TempV1,Value;
to:
for ( long i = 0 ; i < iNumObjs ; i++ )
{
COleVariant vV1, vV2, vV3;
CString TempV1,Value;
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]
|
|
|
|
|
Aleady try this and this is not helping to my mem leak ...
|
|
|
|
|
Strange, it should.
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]
|
|
|
|
|
I know that its strange
|
|
|
|
|
I mean the origina posted code was wrong.
On the other hand, if you're still experiencing memory leaks, probably there's a problem elsewhere. Does the dump of the memory block give you any insight?
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]
|
|
|
|
|
The place of the leak is there - i check it be return in the first line of the method - and its does not give me the leak.
the dump mem deos not help.
|
|
|
|
|
Why do you assume that all fo the three input arrays have the same size?
What do the arrays contain (i.e. what are the actual parameters of the call)?
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]
|
|
|
|
|
So where is the correspond OleUninitialize ?
system
|
|
|
|
|
Inside AfxPostQuitMessage , called for instance in the WM_NCDESTROY message handler.
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]
|
|
|
|
|
Hi.
I'm getting this warning in my project:
warning C4244: '=' : conversion from 'int' to 'char', possible loss of data
This is the code:
(...)
char resp;
while(op_back!=2)
{
(...)
if(A !=0)
{
do
{
(...)
cout<<"Do you want to modify this object? [Y/N] ";
fflush(stdin); cin>>resp;
resp=toupper(resp);
}while(!(resp=='Y' || resp=='N'));
if(resp=='Y')
{
(...)
Is there an easy way to resolve this warning?
And another warning:
warning C4310: cast truncates constant value
gotoxy(0,1);cout<<char(218);
Thank you!
Thank you
"Failure is always an option."
|
|
|
|
|
What compiler are you using? I can't get any warnings
out of any of that code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm using visual c++ 2008 express edition. The warning levels are at max level (4) ...
This is a uni project.. do you think i should put it back at level 3? Is this warning relevant?
"Failure is always an option."
|
|
|
|
|
FrankMookie wrote: This is a uni project
What is a uni project? Do you mean unicode?
|
|
|
|
|
No.. it's an university project.
"Failure is always an option."
|
|
|
|
|
|
FrankMookie wrote: Is there an easy way to resolve this warning?
Yes:
resp=(char) toupper(resp);
FrankMookie wrote: Is there an easy way to resolve this warning?
And another warning:
warning C4310: cast truncates constant value
gotoxy(0,1);cout<<char(218);
What do you intend to do (as you know char's range is [-128,127] )?
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]
|
|
|
|
|
What about the extended ASCII table? the rage goes to 255 http://www.asciitable.com/[^] .
But I did the experience of changing the "218" to a number between the normal range.. and the warning disapeard.
So.. that means i shouldn't use the extended range?
"Failure is always an option."
|
|
|
|