GLC_lib & GLC_Player Forums
http://www.forum.glc-lib.net/

pure virtual method called
http://www.forum.glc-lib.net/viewtopic.php?f=14&t=862
Page 1 of 1

Author:  joewan chen [ Thu Jan 26, 2012 5:39 pm ]
Post subject:  pure virtual method called

Ubuntu 11.10, gcc 4.6.1.
in main function,these code will cause a "pure virtual method called" run-time error:
Code:
    GLC_ColladaToWorld laColladaLoader;
    QFile f("../../Desktop/daes/gun.dae");
    GLC_World* pWorld = laColladaLoader.CreateWorldFromCollada(f);

if I modify in this way, the run-time error will disappear:
Code:
    GLC_ColladaToWorld laColladaLoader;
    QFile *f = new QFile("../../Desktop/daes/gun.dae");
    GLC_World* pWorld = laColladaLoader.CreateWorldFromCollada(*f);


Maybe it caused by the memory releasing sequence of variables.
I mainly refer this article:http://www.artima.com/cppsource/pure_virtual.html, and I hope this can help you to fix this tiny bug.

2012/2/2
I have fixed this on google code.
http://code.google.com/p/glc/source/detail?r=10
It caused by the sequence of deconstructor of QFile and GLC_ColladaToWorld.

I also want to know:
is creating a branch on google code complied with GPL?
If you hate that, I will delete this project immediately.
In fact, I want to commit into the main trunk of GLC on sf, but I do not know how to and there is no references.

Author:  laumaya [ Thu Feb 02, 2012 10:37 am ]
Post subject:  Re: pure virtual method called

Thanks helping me to make GLC_lib better.
joewan chen wrote:
in main function,these code will cause a "pure virtual method called" run-time error:
Code:
Code:
    GLC_ColladaToWorld laColladaLoader;
    QFile f("../../Desktop/daes/gun.dae");
    GLC_World* pWorld = laColladaLoader.CreateWorldFromCollada(f);

if I modify in this way, the run-time error will disappear:
Code:
Code:
    GLC_ColladaToWorld laColladaLoader;
    QFile *f = new QFile("../../Desktop/daes/gun.dae");
    GLC_World* pWorld = laColladaLoader.CreateWorldFromCollada(*f);


Maybe it caused by the memory releasing sequence of variables.
I mainly refer this article:http://www.artima.com/cppsource/pure_virtual.html, and I hope this can help you to fix this tiny bug.


Yes this error is caused by memory releasing sequence of variables : GLC_ColladaToWorld and QFile.
But, the better way to load a 3d file is to use GLC_Factory class like this :
Code:
    QFile file("../../Desktop/daes/gun.dae");
   m_World= GLC_Factory::instance()->createWorldFromFile(file);

joewan chen wrote:
I have fixed this on google code.
http://code.google.com/p/glc/source/detail?r=10
It caused by the sequence of deconstructor of QFile and GLC_ColladaToWorld.

Your fix change the interface of the class GLC_ColladaToWorld... I don't like this.
I prefer to had these 2 lines at the end of GLC_World* GLC_ColladaToWorld::CreateWorldFromCollada(QFile &file)
Code:
   m_pFile->close();
   m_pFile= NULL;

It's done :D
joewan chen wrote:
I also want to know:
is creating a branch on google code complied with GPL?
If you hate that, I will delete this project immediately.
In fact, I want to commit into the main trunk of GLC on sf, but I do not know how to and there is no references.

GLC_lib is OpenSource project, so there is no problems to create a branch on google code.
Sorry, but at this time, I prefer to be the only person which can change code on the GLC_lib repository.
@+

Author:  joewan chen [ Thu Feb 02, 2012 3:00 pm ]
Post subject:  Re: pure virtual method called

first,your solution is much simpler and cleaner.
but I still think that passing a const string reference as method parameter should be much better.
In one word, this problem has been solved and thanks for your suggestions.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/