[SOLVED!!] Access Violation while Subscribing to an Event

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

Browser12
Not too shy to talk
Not too shy to talk
Posts: 42
Joined: Thu Jan 24, 2008 06:30
Location: UW-Madison
Contact:

[SOLVED!!] Access Violation while Subscribing to an Event

Postby Browser12 » Fri Jan 25, 2008 06:08

Mkay I'm stuck again...

System:
MSVC++ 6.0 with sp6
CEGUI 0.4.1 (binary installed)
STLport 4.6.2

I'll send you the abbreviated version of my code... hopefully it's enough; if not, just let me know.

Code: Select all

VideoManager::InitWidgets(void)
{

   ... (creating menu items)...

   Window* ViewFullscreen = wmgr.createWindow("WindowsLook/MenubarItem",
      "root/menubar/View/popup/fullscreen");
   ViewPopup->addChildWindow(ViewFullscreen);
   ViewFullscreen->setText("Toggle Fullscreen");
   ViewFullscreen->subscribeEvent(MenuItem::EventClicked,
      Event::Subscriber(&VideoManager::ToggleFullscreen, this));
}

bool VideoManager::ToggleFullscreen(const EventArgs& args)
{
   this->screen = SDL_SetVideoMode(640, 480, 24, SDL_OPENGL | SDL_SWSURFACE);
   return true;
}


(my toggle fullscreen doesn't actually toggle right now, but that's beside the point... well, unless someone knows how to toggle fullscreen without X11)

Anyways, all I can get out of my compiler is Access Violation (goes away if the event subscription is commented out). If there's some way to get more details on what's goin down, I'd be happy to run any diagnostics.

I really appreciate your help :X
Sorry for bugging you guys again so soon...

edit: :[ nothin? Let me know if you need more information or anything... ^^;
Last edited by Browser12 on Mon Feb 11, 2008 20:41, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jan 29, 2008 10:02

Hi,

Nothing jumped out as being obviously wrong (though that does not mean I didn't just miss it :) ).

Err... How about a backtrace/callstack ?

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Jan 29, 2008 11:37

Have a read through MenuAndPopup, which may provide some useful features.

I usually play with the TaharezLook rather than the WindowsLook so may be off the mark. Shouldn't you be adding a menu item to the menu bar rather than a menu bar item?

Browser12
Not too shy to talk
Not too shy to talk
Posts: 42
Joined: Thu Jan 24, 2008 06:30
Location: UW-Madison
Contact:

Postby Browser12 » Tue Jan 29, 2008 18:35

firstly, thanks sooo much for the replies ^^

@Rackle: Yeah, I read through MenuAndPopup which is where I got some syntax for initializing my menu... I think in WindowsLook, the menu item just happens to be called MenubarItem instead (I initially tried MenuItem and got a crash 'til I looked through the LooknFeel)

@Eddie: I don't suppose you'd be able to tell me how to do that in MSVC++ 6? :oops: I'll try to figure it out in the meantime, but I've never done it before.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jan 29, 2008 21:07

Browser12 wrote:@Eddie: I don't suppose you'd be able to tell me how to do that in MSVC++ 6? :oops: I'll try to figure it out in the meantime, but I've never done it before.

You just need to run the app you're building in the debugger. IIRC the call stackpane is in the lower-right potion of the display (though it's been some years since I used MSVC++ 6, so I could be very wrong!)

A couple of things you'll need to consider:
* Ensure you set up the project settings so that the working directory for the debugging session is set to the correct place (it's in the settings somewhere - don't ask me where though :lol:) - if you do not do this you'll just crash out due to not being able to find the datafiles.

* If you're running a full-screen app, you'll likely need to switch to windowed mode if possible (else you'll not see the debugger window). Alternatively you could try some remote debugging - that's always fun to set up :)

HTH

CE.

Browser12
Not too shy to talk
Not too shy to talk
Posts: 42
Joined: Thu Jan 24, 2008 06:30
Location: UW-Madison
Contact:

Postby Browser12 » Tue Jan 29, 2008 23:32

Alright, I've been looking around and the only "Call StacK" in debug mode gives me this nonsense, if I go until it crashes:

Code: Select all

 cccccccc()
NTDLL! 7c9037bf()
NTDLL! 7c90378b()
NTDLL! 7c90eafa()
NTDLL! 7c90378b()
NTDLL! 7c90eafa()


if I go until the line before the subscription, it gives me this:

Code: Select all

Interface::InitWidgets() line 80
Interface::Interface() line 17
ManagerTemplate<Interface>::Start() line 27 + 34 bytes
AppLoop::AppLoop() line 30
SDL_main(int 1, char * * 0x0012feb4) line 33
WORLDWRITER! main + 209 bytes
WORLDWRITER! WinMain@16 + 157 bytes
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! 7c816fd7()


There's one small difference now, by the by. I put the initwidgets() function into a different object (so now i pass the Subscriber the address of my VideoManager instead of 'this'). It does the same thing both ways, though.

Anyways, is that what you needed? :X It doesn't look to helpful to me, so I'm thinking I'm not doing it right... let me know though.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Jan 30, 2008 09:29

Browser12 wrote:Anyways, is that what you needed? :X It doesn't look to helpful to me, so I'm thinking I'm not doing it right... let me know though.

Yeah, that's what I was asking for. Buy you're right that in this case it's not helpful :(

I had a browse of the commit logs to see if we fixed any bugs that might be affecting you - but nothing jumped out at me.

Did you build the demo apps for CEGUI? And do they work as expected?

Browser12
Not too shy to talk
Not too shy to talk
Posts: 42
Joined: Thu Jan 24, 2008 06:30
Location: UW-Madison
Contact:

Postby Browser12 » Wed Jan 30, 2008 23:14

I haven't built any 'demo apps' per se, due to the scary project configuration of SDL, OpenGL, and CEGUI all together :shock:
I've just been sort of stealing syntax and integrating CEGUI into my application where I found updated stuff from various tuts, since some parts of some are out of date, some aren't, etc.
(I've never gotten a subscribe event to work in any context, though. This is the first one I've tried.)
If there are a couple 'demo apps' you'd like me to try and make, I'd be more than happy to though :]

EDIT: before I posted this, I just spent some time creating a new application that simply renders a blank scene, injects input from SDL, and has a menubar with 1 button. Subscribing an event to the button still crashes the program. :[

I'm stumped.. maybe this just wasnt meant to be. D:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Jan 31, 2008 09:19

When I say demo apps, I mean the ones that come with CEGUI; the ones beneath the Samples directory. Basically these act as a test/sanity check of the build - if they work, any issues are likely issues in your own code or project configs. Basically it just helps to narrow down the scope of what could be at fault.

The only other things I can think of off the top of my head to check are that the app you are building is linking to the same c/c++ runtime that was used to build the CEGUI library and associated components (so in this case the STLport one, right?).

As an aside from all that, I have to ask, why VC++ 6?

Browser12
Not too shy to talk
Not too shy to talk
Posts: 42
Joined: Thu Jan 24, 2008 06:30
Location: UW-Madison
Contact:

Postby Browser12 » Thu Jan 31, 2008 16:53

Ah, sorry. Didn't even realize there were demo apps :]
In all honesty, I'm not sure about whether or not my project is linked with this STLport runtime which you speak of. I'm rather terrible at this stuff...
Also, is there a tut for building these demo apps? Should they just compile right out of the box, so to speak, or do I have to build anything, add any links to the projects, etc etc? Right now if I compile Demo4, it wants a ceguisamplehelper_d.dll. If I compile SampleHelper, it gives me like 48 errors.

Thanks for all your continued help... I wish I knew enough to do some of these things on my own. I do hate bugging you guys so much @_@

On a side note, no idea. I don't remember how, but I've just always had MSVC++ 6 and it's what I used since I read my C++ book in middle school... so thats just what I'm used to, I guess. Though as you can tell, I've not ventured very far outside of the compiler before ^^; besides the occasional foray into directx or opengl.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Thu Jan 31, 2008 18:13

You could download Visual Studio 2008 Express. That would make it simpler to build Cegui; that .sln generated by premake would work right away. There is a thread containing "some" information on Compiling Cegui v0.5 from source.

Beware that the express edition does not allow you to build Setup applications (at least in the 2005 edition it was the case).

Browser12
Not too shy to talk
Not too shy to talk
Posts: 42
Joined: Thu Jan 24, 2008 06:30
Location: UW-Madison
Contact:

Postby Browser12 » Thu Jan 31, 2008 18:27

Cool Rackle, thanks for that :]
I hadn't thought of switching compilers really. However, this program is my game's "World Writer"... a tile laying, object placing, file-exporting map editor. So I guess it doesn't really matter what I compile it in, as I can still program my main game in MSVC++ (the game itself doesn't use CEGUI.. just wanted something quick for the World Writer).

Is Express much different from the full version?
I have some money, so buying a full version of a compiler isn't really an issue.

I'd still like to fix CEGUI in MSVC++ :twisted:
but at least this would give me an alternative route to work on in the meantime and possibly serve as a solution if I can't get the other one to work.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Thu Jan 31, 2008 19:46

I'd be curious to know the release date of MSVC v6. The environment itself worked well, the IDE did not have major problems.

Is Express much different from the full version?
I have some money, so buying a full version of a compiler isn't really an issue.


The difference I'm aware of are that Express is free and does not allow the creation of Setup projects. There are bound to also be other differences but I do not know them. Projects (.sln) created with the full version can still be opened with the Express version. I suspect that MSVC v6 is 10 years old. There have been many advances in the last decade. You could try the Express edition and see how it handles.

Browser12
Not too shy to talk
Not too shy to talk
Posts: 42
Joined: Thu Jan 24, 2008 06:30
Location: UW-Madison
Contact:

Postby Browser12 » Sun Feb 03, 2008 07:00

ok SO.

Negative. :[
This is what I did:

- got MSVC9.0 (2008) express
- got 0.4.1 for MSVC8.0 (2005) (there was no 2008)
- linked it all up
- got my program running (with the exception of the CEGUI interface code, which I have to comment out. more on this below..)

First problem:
Is there different syntax or something for creating a CEGUI menu in 2008? Because the syntax that works for me in MSVC6.0 doesn't work at all here.
the ->addChildWindow methods for menu items and tabcontrol stuff are causing errors.
like randomly half of my menu commands won't work.. the other half will. but that's not as important to me right now. Because the 2nd question...

Second problem:
If I just attach a pushbutton to the menubar (or root), it will run. however, subscribing an event to it crashes. However, this could be from the First Problem. Since like half the menu commands are crashing.


Also, the second reason I got 2008... I built these demo apps.
I got all of them to build (after a lot of work @_@) without problems.
Is there something more to be done with them? Anything that I can do with these to give you more information on what's going on?

ok, now here's my current interface code... take a look. This syntax works perfectly for me on MSVC6.0, but not at all on MSVC9.0. Not only that, I can't get it to work on MSVC9.0 for the life of me... I've tried changing a bunch of it, and none of it worked.

It crashes when I try to attach File (a MenuItem) to the Menubar window.
I can attach a pushbutton to the Menubar window. Stuff like that... certain things will attach, others won't, and none of the crashes that end on a ->addChildWindow leave anything in my CEGUI log.

Code: Select all

   WindowManager& wmgr = WindowManager::getSingleton(); // Init pointer to Window Manager
   Window* Root = wmgr.createWindow("DefaultWindow", "root"); // Create root window
   System::getSingleton().setGUISheet(Root); // Set root window

   Window* Menubar = wmgr.createWindow("WindowsLook/Menubar", "root/menubar");
   Root->addChildWindow(Menubar);
   Menubar->setSize(Size(1.0f, 0.06f));
   
      MenuItem* File = static_cast<MenuItem*>(wmgr.createWindow("WindowsLook/MenubarItem", "root/menubar/file"));
      File->setText("File");
      Menubar->addChildWindow(File);
      
         PopupMenu* FilePopup = static_cast<PopupMenu*>(wmgr.createWindow("WindowsLook/PopupMenu", "root/menubar/file/popup"));
         File->addChildWindow(FilePopup);
         FilePopup->setSize(Size(2.5f, 5.5f));
   
            Window* FileNew = wmgr.createWindow("WindowsLook/MenubarItem", "root/menubar/file/popup/new");
            FilePopup->addChildWindow(FileNew);
            FileNew->setSize(Size(0.2f, 0.05f));
            FileNew->setText("New");
   
            Window* FileOpen = wmgr.createWindow("WindowsLook/MenubarItem", "root/menubar/file/popup/open");
            FilePopup->addChildWindow(FileOpen);
            FileOpen->setSize(Size(0.2f, 0.05f));
            FileOpen->setText("Open");
   
            Window* FileSave = wmgr.createWindow("WindowsLook/MenubarItem", "root/menubar/file/popup/save");
            FilePopup->addChildWindow(FileSave);
            FileSave->setSize(Size(0.2f, 0.05f));
            FileSave->setText("Save");

            Window* FileExit = wmgr.createWindow("WindowsLook/MenubarItem", "root/menubar/file/popup/exit");
            FilePopup->addChildWindow(FileExit);
            FileExit->setSize(Size(0.2f, 0.05f));
            FileExit->setText("Exit");

      Window* View = wmgr.createWindow("WindowsLook/MenubarItem", "root/menubar/view");
      Menubar->addChildWindow(View);
      View->setText("View");

         PopupMenu* ViewPopup = static_cast<PopupMenu*>(wmgr.createWindow("WindowsLook/PopupMenu", "root/menubar/view/popup"));
         View->addChildWindow(ViewPopup);
         ViewPopup->setSize(Size(2.5f, 5.5f));

            Window* ViewFullscreen = wmgr.createWindow("WindowsLook/MenubarItem", "root/menubar/view/popup/fullscreen");
            ViewPopup->addChildWindow(ViewFullscreen);
            ViewFullscreen->setText("Toggle Fullscreen");
            //ViewFullscreen->subscribeEvent(MenuItem::EventClicked, Event::Subscriber(&Interface::EventFunctions::ViewFullscreen, &this->EventHandler));


   TabControl* Tabs = static_cast<TabControl*>(wmgr.createWindow("WindowsLook/TabControl", "root/tabs"));
   Root->addChildWindow(Tabs);
   Tabs->setSize(Size(0.2f, 0.94f));
   Tabs->setPosition(Vector2(0.8f,0.06f));

      Window* TabTiles = wmgr.createWindow("DefaultWindow", "root/tabs/tiles");
      TabTiles->setText("Tiles");
      Tabs->addChildWindow(TabTiles);

      Window* TabObjects = wmgr.createWindow("DefaultWindow", "root/tabs/objects");
      TabObjects->setText("Objects");
         TabControl* ObjectsTabs = static_cast<TabControl*>(wmgr.createWindow("WindowsLook/TabControl","root/tabs/objectstabs"));
         TabObjects->addChildWindow(ObjectsTabs);
         ObjectsTabs->setSize(Size(1.0f,1.0f));
         ObjectsTabs->setPosition(Vector2(0,0));
            
            Window* ObjectsTabStatics = wmgr.createWindow("DefaultWindow", "root/tabs/objects/statics");
            ObjectsTabStatics->setText("Statics");
            ObjectsTabs->addChildWindow(ObjectsTabStatics);

            Window* ObjectsTabDynamics = wmgr.createWindow("DefaultWindow", "root/tabs/objects/dynamics");
            ObjectsTabDynamics->setText("Dynamics");
            ObjectsTabs->addChildWindow(ObjectsTabDynamics);
      Tabs->addChildWindow(TabObjects);

      Window* TabBeings = wmgr.createWindow("DefaultWindow", "root/tabs/beings");
      TabBeings->setText("Beings");
         TabControl* BeingsTabs = static_cast<TabControl*>(wmgr.createWindow("WindowsLook/TabControl","root/tabs/beingstabs"));
         TabBeings->addChildWindow(BeingsTabs);
         BeingsTabs->setSize(Size(1.0f,1.0f));
         BeingsTabs->setPosition(Vector2(0,0));
            
            Window* BeingsTabEnemies = wmgr.createWindow("DefaultWindow", "root/tabs/beings/enemies");
            BeingsTabEnemies->setText("Enemies");
            BeingsTabs->addChildWindow(BeingsTabEnemies);
            
            Window* BeingsTabNPCs = wmgr.createWindow("DefaultWindow", "root/tabs/beings/npcs");
            BeingsTabNPCs->setText("NPCs");
            BeingsTabs->addChildWindow(BeingsTabNPCs);
      Tabs->addChildWindow(TabBeings);


OK sorry for the INCREDIBLY long message... if you read all that, you are a god. O__o

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sun Feb 03, 2008 11:04

Hi,

You really need a library version built for your compiler - which does not exist at this time.

It is my intention to issue dependency packages and a prebuilt binary CEGUI 0.5 version for VC++ 9 / 2008 later on today. I am actually working on this as I type.

Watch this space.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 26 guests