Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Array & Gdiplus::Pen problem
Array & Gdiplus::Pen problem [message #10841] Wed, 01 August 2007 15:37 Go to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

1>C:\uppdevel\uppsrc\Core/Vcont.h(132) : error C2512: 'Gdiplus::Pen' : no appropriate default constructor available
C:\uppdevel\uppsrc\Core/Vcont.h(132) : while compiling class template member function 'void Upp::Array<T>::Init(void **,void **)'
with
[ T=Gdiplus::Pen]
.\Layers.cpp(39) : see reference to class template instantiation 'Upp::Array<T>' being compiled
with [ T=Gdiplus::Pen ]

Pen dosn't have Pen() constructor so how i can use any container with Pen , Vector , Array ?

Layers.cpp(39)
pens.Reserve(Globals::RoadCategories);

Any suggestions ?

[Updated on: Wed, 01 August 2007 15:38]

Report message to a moderator

Re: Array & Gdiplus::Pen problem [message #10847 is a reply to message #10841] Wed, 01 August 2007 16:14 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I do not think it is Reserve.

Can you post more Array related code please?

Mirek
Re: Array & Gdiplus::Pen problem [message #10849 is a reply to message #10841] Wed, 01 August 2007 16:30 Go to previous messageGo to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

It was exaclty Reserve
When i mark out Reserve i got another place

Pen *p;
...........
p = new Pen(this->m_pOutlin.....
.........
pens.Add( p );

And then it failed at Add

So finaly i had no solution and switched
from
void MetaLayer::GetPens(int type, Array<Pen> & pens) const

to
void MetaLayer::GetPens(int type, Vector<Pen *> & pens) const

and by hand managing memory of Pens


Re: Array & Gdiplus::Pen problem [message #10850 is a reply to message #10849] Wed, 01 August 2007 16:46 Go to previous messageGo to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

Tested more and:
When i comment out other method below

	void MetaLayer::GetSimplePens(int type, Array<Pen> & pens) const
	{
		pens.SetCount(Globals::RoadCategories);
		if (type == 0)
		{
			for (int i = 0; i < Globals::RoadCategories; i++)
			{
				pens.Set(i, new Pen(Color_(0,0,0), 3.));
				pens[i].SetEndCap(Gdiplus::LineCapDiamondAnchor);
				pens[i].SetStartCap(Gdiplus::LineCapDiamondAnchor);
			}
		}
		else if (type == 1)
		{
			for (int i = 0; i < Globals::RoadCategories; i++)
			{
				pens.Set(i, new Pen(Color_(255,0,0), 1.));
				pens[i].SetStartCap (Gdiplus::LineCapDiamondAnchor);
				pens[i].SetEndCap (Gdiplus::LineCapDiamondAnchor);
			}
		}
		else
			for (int i = 0; i < Globals::RoadCategories; i++)
				pens.Set(i, new Pen(Color_(0,0,0), 3));
		
	}



I can compile code with earlier metohod
When i enable this metod the compiler fails at other metod below!!!!

void MetaLayer::GetPens(int type, Array<Pen> & pens) const


WHats wrong with Array ?
Re: Array & Gdiplus::Pen problem [message #10851 is a reply to message #10850] Wed, 01 August 2007 16:51 Go to previous messageGo to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

After changing code to below everything is ok
Propably SetCount was the error but complier message pointed to incorect line in code ...


	void MetaLayer::GetSimplePens(int type, Array<Pen> & pens) const
	{
		pens.Reserve(Globals::RoadCategories);
		Pen *p;
		if (type == 0)
		{
			for (int i = 0; i < Globals::RoadCategories; i++)
			{
				p = new Pen(Color_(0,0,0), 3.);
				p->SetEndCap(Gdiplus::LineCapDiamondAnchor);
				p->SetStartCap(Gdiplus::LineCapDiamondAnchor);
				pens.Add(p);
			}
		}
		else if (type == 1)
		{
			for (int i = 0; i < Globals::RoadCategories; i++)
			{
				p = new Pen(Color_(255,0,0), 1.);
				p->SetStartCap (Gdiplus::LineCapDiamondAnchor);
				p->SetEndCap (Gdiplus::LineCapDiamondAnchor);
				pens.Add(p);
			}
		}
		else
			for (int i = 0; i < Globals::RoadCategories; i++)
				pens.Add(new Pen(Color_(0,0,0), 3));
		
	}




Re: Array & Gdiplus::Pen problem [message #10854 is a reply to message #10851] Wed, 01 August 2007 18:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Obviously, SetCount requires default constructor - you are creating default constructed object in the process...

BTW, this is only required if the new number of elements is greater, but SetCount has to contain the increase variant too.

Anyway, if you are reducing the number of elements, you can use also Trim (without default constructor requirement).

Mirek
Re: Array & Gdiplus::Pen problem [message #10864 is a reply to message #10854] Wed, 01 August 2007 19:53 Go to previous messageGo to next message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

I understand now why , Array gives me reference to inside element so they cannot be null , SetCount causes this to happen

Hoever there is a very wrong thing in MSVC8/NTL don't know in which propably in NTL.

Imagine one cpp file conatining

class Pen
{
Pen(int a){}
}

//somewhere in code compiled first....

Array<Pen> x;
x.Reserve(10);
x.Add(new Pen(0));

//somewhere in code compiled after ....
Array<Pen> x;
x.SetCount(10);


Compiler will fail at Reserve
Then when You comment out Reserve, compiler will fail at Add!!!!
This is difficult sometimes to trace where is the deffinition which causes problem ...
And this is why i started posting this topic.
Re: Array & Gdiplus::Pen problem [message #10868 is a reply to message #10864] Wed, 01 August 2007 20:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I think that the trouble is usually caused by the fact that template implementation code is compiled AFTER everything else, way after concrete methods are used.

And, BTW, how could NTL affect error messages? Smile

Mirek
Re: Array & Gdiplus::Pen problem [message #10871 is a reply to message #10868] Wed, 01 August 2007 23:03 Go to previous message
arturbac is currently offline  arturbac
Messages: 91
Registered: May 2007
Location: Reda, Poland
Member

I Don't known Smile
Previous Topic: #ifdef PLATFORM_POSIX #include <bits/atomicity.h> for POSIX ?
Next Topic: Compatibility change
Goto Forum:
  


Current Time: Fri Mar 29 15:53:34 CET 2024

Total time taken to generate the page: 0.01282 seconds