View unanswered posts | View active topics It is currently Sat Sep 22, 2018 9:45 pm



Reply to topic  [ 3 posts ] 
 pure virtual method called 
Author Message

Joined: Tue Jan 24, 2012 11:15 am
Posts: 5
Post 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.


Thu Jan 26, 2012 5:39 pm
Profile
Site Admin

Joined: Sun Jan 03, 2010 4:27 pm
Posts: 390
Post 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.
@+


Thu Feb 02, 2012 10:37 am
Profile

Joined: Tue Jan 24, 2012 11:15 am
Posts: 5
Post 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.


Thu Feb 02, 2012 3:00 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.