Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 1522 problems with template

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
mnd Posted - Jun 16 2006 : 03:07:03 AM
Hello,

I'm having problems with heavy use of templates, I'm using an adobe sdk for indesign (you can see here: http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=4126), I'm trying to reproduce it but I have mixed results, in some case it works, in others not.

These are the classes I built in order to reproduce the problem:

class IFooBase
{
public:
	virtual void AddRef() = 0;
	virtual void Release() = 0;
	virtual IFooBase* QueryInterface(int32 id) const = 0;
};

class IFoo : public IFooBase
{
public:
	virtual int32 GetBar() = 0;
};

class IFooSession: public IFooBase
{
public:
	virtual int32 GetSessionID() = 0;
};

template <class IFace>
class IntfPtr
{
public:
	explicit  IntfPtr(IFace* p) 
		: fFace(p) {
		(void) static_cast<const IFooBase*>(p);
	}

	IntfPtr(const IFooBase* p, int32 id)
		:  fFace(QueryInterface_(p, id)) {}

	IFace* forget() {
		IFace* result = fFace;
		fFace = 0;
		return result;
	} 

	IFace * operator ->() const { return fFace; }

protected:
	static IFace* QueryInterface_(const IFooBase* p, int32 id) 
		{ return p ? static_cast<IFace*>(p->QueryInterface(id)) : nil; }

protected:
	IFace* fFace;
};

template <class IFace> 
class FooUtils
{
public:
	inline FooUtils() : fPtr(nil)
	{
		IntfPtr<IFace> utilsIntf(fSession, 0);
		fPtr = utilsIntf.forget();
	};

	inline IFace* operator ->() const { return static_cast<IFace*>(fPtr); }

protected:
	IFooBase* fPtr;
	IFooSession* fSession;
};

template <class Interface>
class CFooBase : public Interface
{
public:
	inline CFooBase(IFooBase* base)
		: fPtr(base)
	{}

	inline void AddRef() {}
	inline void Release() {}

protected:
	IFooBase* fPtr;
};

class CFoo : CFooBase<IFoo>
{
public:
	CFoo(IFooBase* base) : CFooBase<IFoo>(base) {}

	int32 GetBar() { return 32; }
};

class CTest
{
public:
	CTest() {
		FooUtils<IFoo> foo;
		foo->

	}
};


At first it gave me the wrong results (I've taken the screenshot but I was unable to include it in this topic, anyway the method list was only the constructor of FooUtils and the protected member fPtr) and later, when I tried to expand the sample (adding IFooSession for example), it gave me right results (all the methods of IFoo and IFooBase).

However it is not working with the AdobeSDK that exibits similar classes (I don't know if the problem depends of the use of precompiled headers, use of inline methods or on the fact that all the interfaces and helper classes are on their own include file).

I've to say that it is working with build 1446.

Kindest Regards,

- mn
5   L A T E S T    R E P L I E S    (Newest First)
mnd Posted - Jun 20 2006 : 05:24:56 AM
Is fixed in both!

- mn
feline Posted - Jun 19 2006 : 5:40:24 PM
this is good news! is it fixed only with your test code, or also with the Adobe SDK code?
mnd Posted - Jun 19 2006 : 09:41:34 AM
after installing build 1524 the problem seems vanished!
mnd Posted - Jun 19 2006 : 02:35:33 AM
Ciao,

The problem I have is with the adobe sdk (here - http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=4126 - you can read how to download and install), I tried to reproduce the problem with some classes of my own and at first I was able to reproduce it as this screenshot deomstrate:



but later on the same test code didn't show the problem anymore even if I still have the problem with the SDK.

The code is in .cpp code.

In the sample code I provided I noticed that when I type the last foo-> the autocompletion is not displayed, I had to press CTRL+Space and the first listbox that is displayed is the wrong one (the same that I've taken in the screenshot) and then after some delays (100 or 200 milliseconds) the correct one is displayed.

It looks like the first time the listbox was provided only the wrong one was displayed. With the sdk, however, it is always displayed the wrong one.

Regards,

- mn


VA_X.dll file version 10.3.1522.0 built 2006.06.08
Licensed to:
VA X: [email protected] (1-user license) Support ends 2007.01.13
VAOpsWin.dll version 1.3.3.2
VATE.dll version 1.0.5.7
DevEnv.exe version 7.10.3077.0
msenv.dll version 7.10.3077.0
Font: ProFontWindows 15(Pixels)
Comctl32.dll version 5.82.2900.2180
Windows XP 5.1 Build 2600 Service Pack 2
Single processor

Platform: Custom
Stable Includes:
c:\\program files\\microsoft visual studio .net 2003\\vc7\\include;
c:\\program files\\microsoft visual studio .net 2003\\vc7\\atlmfc\\include;
c:\\program files\\microsoft visual studio .net 2003\\vc7\\PlatformSDK\\include\\prerelease;
c:\\program files\\microsoft visual studio .net 2003\\vc7\\PlatformSDK\\include;
c:\\program files\\microsoft visual studio .net 2003\\sdk\\v1.1\\include;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\includes;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\architecture;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\cjk;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\colormgmt;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\graphics;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\incopy;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\interactive;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\interactive\\ui;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\layout;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\tables;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\text;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\ui;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\utils;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\workgroup;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\interfaces\\xmedia;
C:\\build\\main103\\src\\contrib\\Adobe\\InDesign\\ID-4.0\\source\\public\\widgets\\includes;
C:\\build\\main103\\src\\contrib\\jace\\1.1\\release\\include;

Library Includes:
c:\\program files\\microsoft visual studio .net 2003\\vc7\\atlmfc\\src\\mfc;
c:\\program files\\microsoft visual studio .net 2003\\vc7\\atlmfc\\src\\atl;
c:\\program files\\microsoft visual studio .net 2003\\vc7\\crt\\src;

Other Includes:

feline Posted - Jun 17 2006 : 1:17:20 PM
in order to post a picture you have to host it somewhere, and then link to it from here. personally i have a free account at photobucket.com for posting pictures. there are a range of sites like this that people use.

i have placed this entire block of code into a header file, using VS2003 and a C++ project, and in the CTest class i am seeing:



which, if i have followed the code correctly, is correct.

which IDE are you using? how have you organised the code? is the code in a header file on its own?
if you have a test project where you can make this go wrong then you can email it to me for me to try.
it could be that when you first open the IDE, or first load this project, or the first time you ask for a listbox it goes wrong.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000