Home » U++ Library support » U++ Core » Array & Gdiplus::Pen problem
Array & Gdiplus::Pen problem [message #10841] |
Wed, 01 August 2007 15:37 |
|
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 #10849 is a reply to message #10841] |
Wed, 01 August 2007 16:30 |
|
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 |
|
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 |
|
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 #10864 is a reply to message #10854] |
Wed, 01 August 2007 19:53 |
|
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.
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 29 08:36:19 CEST 2024
Total time taken to generate the page: 0.02861 seconds
|