[Solved]CEGUI::AlreadyExistsException

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

[Solved]CEGUI::AlreadyExistsException

Postby gams » Sun May 24, 2015 13:34

Hi
I'm currently porting from 0.7 to 0.8 and when I finally got project compiled I get exception AlreadyExistsException thrown. Now I don't know where the exception is thrown from and why all I know is that call to CEGUI::System::create(renderer); causes it.



Code: Select all

24/05/2015 15:53:47 (Std)    ********************************************************************************
24/05/2015 15:53:47 (Std)    * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM       -------- *
24/05/2015 15:53:47 (Std)    ********************************************************************************
24/05/2015 15:53:47 (Std)    ---- Version: 0.8.4 (Build: May 23 2015 Microsoft Windows MSVC++ 10.0 32 bit) ----
24/05/2015 15:53:47 (Std)    ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.  TextureTarget support enabled via FBO extension. ----
24/05/2015 15:53:47 (Std)    ---- XML Parser module is: CEGUI::TinyXMLParser - Official tinyXML based parser module for CEGUI ----
24/05/2015 15:53:47 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
24/05/2015 15:53:47 (Std)    ---- Scripting module is: None ----
24/05/2015 15:53:47 (Std)    ********************************************************************************
24/05/2015 15:53:47 (Std)    * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM         -------- *
24/05/2015 15:53:47 (Std)    ********************************************************************************
24/05/2015 15:53:47 (Std)    
24/05/2015 15:53:47 (Std)    ---- Begining CEGUI System initialisation ----
24/05/2015 15:53:47 (Std)    [CEGUI::ImageManager] Singleton created (038DE558)
24/05/2015 15:53:47 (Std)    [CEGUI::ImageManager] Registered Image type: BasicImage
24/05/2015 15:53:47 (Std)    CEGUI::FontManager singleton created. (038E2930)
24/05/2015 15:53:47 (Std)    CEGUI::WindowFactoryManager singleton created
24/05/2015 15:53:47 (Std)    ---- Adding pre-registered WindowFactory objects ----
24/05/2015 15:53:47 (Std)    WindowFactory for 'DefaultWindow' windows added. (038DE0D8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'DragContainer' windows added. (038DE258)
24/05/2015 15:53:47 (Std)    WindowFactory for 'ScrolledContainer' windows added. (038DE3D8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'ClippedContainer' windows added. (038DE5D0)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/PushButton' windows added. (038DE750)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/RadioButton' windows added. (038DE8D0)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Combobox' windows added. (038DEA58)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ComboDropList' windows added. (038DED10)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Editbox' windows added. (038DEB10)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/FrameWindow' windows added. (038DF090)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ItemEntry' windows added. (038DEE90)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Listbox' windows added. (038DF2E0)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ListHeader' windows added. (038DF460)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ListHeaderSegment' windows added. (038DF5E0)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Menubar' windows added. (038DF760)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/PopupMenu' windows added. (038DF8E0)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/MenuItem' windows added. (038DFA60)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/MultiColumnList' windows added. (038DFBE0)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/MultiLineEditbox' windows added. (038DFD60)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ProgressBar' windows added. (038DFEE0)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ScrollablePane' windows added. (038E00E8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Scrollbar' windows added. (038E0268)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Slider' windows added. (038E03E8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Spinner' windows added. (038E0568)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/TabButton' windows added. (038E06E8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/TabControl' windows added. (038E0868)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Thumb' windows added. (038E09E8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Titlebar' windows added. (038E0B68)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ToggleButton' windows added. (038E0CE8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Tooltip' windows added. (038E0F28)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/ItemListbox' windows added. (038E10A8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/GroupBox' windows added. (038E1228)
24/05/2015 15:53:47 (Std)    WindowFactory for 'CEGUI/Tree' windows added. (038E13A8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'LayoutCell' windows added. (038E1528)
24/05/2015 15:53:47 (Std)    WindowFactory for 'HorizontalLayoutContainer' windows added. (038E16A8)
24/05/2015 15:53:47 (Std)    WindowFactory for 'VerticalLayoutContainer' windows added. (038E1828)
24/05/2015 15:53:47 (Std)    WindowFactory for 'GridLayoutContainer' windows added. (038E19A8)
24/05/2015 15:53:47 (Std)    CEGUI::WindowManager singleton created (038DEBC8)
24/05/2015 15:53:47 (Std)    CEGUI::SchemeManager singleton created. (038E4F50)
24/05/2015 15:53:47 (Std)    CEGUI::GlobalEventSet singleton created. (03083A20)
24/05/2015 15:53:47 (Std)    CEGUI::AnimationManager singleton created (038E0060)
24/05/2015 15:53:47 (Std)    CEGUI::WidgetLookManager singleton created. (038DEF98)
24/05/2015 15:53:47 (Std)    CEGUI::WindowRendererManager singleton created (038DE5A0)
24/05/2015 15:53:47 (Std)    CEGUI::RenderEffectManager singleton created (038E2310)
24/05/2015 15:53:47 (Std)    Created WindowFactory for 'DefaultWindow' windows.
24/05/2015 15:53:47 (Error)   CEGUI::AlreadyExistsException in function 'void __thiscall CEGUI::WindowFactoryManager::addFactory(class CEGUI::WindowFactory *)' (..\..\..\cegui-0.8.4\cegui\src\WindowFactoryManager.cpp:82) : A WindowFactory for type 'DefaultWindow' is already registered.
24/05/2015 15:53:47 (Std)    Deleted WindowFactory for 'DefaultWindow' windows.



This maybe irrelevant but I don't know if I did the right thing by changing from this 0.7 code:

Code: Select all

Imageset &greenBarImg = CEGUI::ImagesetManager::getSingleton().createFromImageFile("greenBar","greenBar.png","");

to this:

Code: Select all

Image  &greenImg = CEGUI::ImageManager::getSingleton().create("greenBar","greenBar.png");



thanks for your help
Last edited by gams on Sun May 24, 2015 15:52, edited 1 time in total.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI::AlreadyExistsException

Postby Ident » Sun May 24, 2015 13:52

Why did you originally post this in "Advanced help"? Is the description not clear enough? :?

We need to know which call caused this or we cannot help you. Catching the exception and looking at the callstack should help: http://stackoverflow.com/questions/3159 ... exceptions

Report back.
CrazyEddie: "I don't like GUIs"

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

Re: CEGUI::AlreadyExistsException

Postby gams » Sun May 24, 2015 14:24

Ident wrote:Why did you originally post this in "Advanced help"? Is the description not clear enough? :?

We need to know which call caused this or we cannot help you. Catching the exception and looking at the callstack should help: http://stackoverflow.com/questions/3159 ... exceptions

Report back.


my apologies I posted this in advanced because it seems tough problem. And I don't know why vs10 is giving me call stack only to CEGUI::System::create and then nothing, I am catching the exception.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI::AlreadyExistsException

Postby Ident » Sun May 24, 2015 14:56

Well then this is probably what causes it. You can simply set a breakpoint in debugging mode to figure out if the other lines of code are ever reached at all. However, I wish to remind you that clearly CEGUI is not a source for Visual Studio support. To learn more about debugging, C++ and Visual Studio please consult other sources. Keep in mind that you will need this knowledge to track down issues in your code (both CEGUI-related and not CEGUI-related) all the time when being a programmer, so if you already have issues here, then you should really start to study the debugging tools you use. Being able to debug well is super-important.

Any chance you initialise CEGUI twice or something like that? Show us your entire initialisation code, and also figure out (using breakpoints) which part is relevant (dont post the code that is never reached). We only care about relevant code, and only CEGUI-related code for now.
CrazyEddie: "I don't like GUIs"

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

Re: CEGUI::AlreadyExistsException

Postby gams » Sun May 24, 2015 15:17

thanks I actually have pretty good grasp of debugging but what I see is happening here is that the exception is thrown from inside cegui source and I don't have this source in my project so debugger cannot track it... Unfortunately I cannot remember now how to include cegui code in my vs project so that it can be debugged.

what I did was that I added the initialization code top of the main and it is still giving same error:

Code: Select all


int main(int argc, char *argv[])
{

 
if(SDL_Init(SDL_INIT_VIDEO) < 0)
 derror string("Failed to init SDL, reason: ") + SDL_GetError();

 if(SDL_SetVideoMode(screenWidth,screenHeight,0,SDL_OPENGL) == NULL)
 {
  derror string("Unable to set OpenGL videomode: ") + SDL_GetError();
 }

CEGUI::OpenGLRenderer& renderer1 = CEGUI::OpenGLRenderer::bootstrapSystem();

CEGUI::System::create(renderer1); // throws AlreadyExistsException

return 0;


EDIT: could it be that cegui is reading the datafiles and encounters two layouts or something with same name?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: CEGUI::AlreadyExistsException

Postby Ident » Sun May 24, 2015 15:43

Like i suspected, you simply create CEGUI System twice. This is pretty exactly what the exception tells you too (or at least indicates).

This is all documented in our official docs: http://static.cegui.org.uk/docs/0.8.0/r ... _bootstrap
CEGUI System is created from within the bootstrap function you call. Don't create it again and please follow the API docu. The official API docu is the best source of info on such things. If something is wrong there or missing please tell us so we can fix it, or fix it yourself by making a bitbucket PR right away.

Regarding debugging with CEGUI source: this is always a good thing to have, simply add the respective pdb files of your CEGUI build next to the CEGUI dll files of your application#s folder, the application that uses CEGUI. This allows to get the symbols, and you will be able to debug in source if you compiled CEGUI on your computer (!). For Debug build these pdb files will exist definitely. For Release build you won't have them so you will need to build CEGUi with RelWithDebug, which might be a tiny bit slower (but way faster than just Debug, which has no optimisation whatsoever) but allows you to debug in Release mode.

Please tell me if this helped you and edit the forum thread accordingly if the problem is [Solved].
CrazyEddie: "I don't like GUIs"

gams
Not too shy to talk
Not too shy to talk
Posts: 39
Joined: Sun May 24, 2015 13:23

Re: CEGUI::AlreadyExistsException

Postby gams » Sun May 24, 2015 15:52

Thanks man it works now.. :) (removed the call to CEGUI::System::create() )


Return to “Help”

Who is online

Users browsing this forum: No registered users and 29 guests