Problem with a slider

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Viper
Just popping in
Just popping in
Posts: 16
Joined: Mon Aug 29, 2005 01:27
Location: US
Contact:

Problem with a slider

Postby Viper » Mon Aug 29, 2005 03:45

I am trying to create a slider, but when I execute the program, I get the following exception:

Code: Select all

Unhandled exception at 0x42c80000 in SpaceRaceD.exe: 0xC0000005: Access violation reading location 0x42c80000.


It always happens on this line of code:

Code: Select all

Slider->setMaxValue(100.0);


Here is a more complete cut of the code:

Code: Select all

        CEGUI::Slider* Slider;
        CEGUI::Window* myTop = wmgr.loadWindowLayout("Layouts/SoundMenu.layout");
   myRoot->addChildWindow(myTop);
   Slider = (CEGUI::Slider*)wmgr.getWindow("sldSound");
   Slider->setMaxValue(100.0);
   Slider->setClickStep(1.0);
   Slider->setCurrentValue((float)g_iSoundVolume);


Any help is greatly appreciated. Thanks :D

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

Re: Problem with a slider

Postby CrazyEddie » Mon Aug 29, 2005 08:01

We'll need to see the layout xml for the file "Layouts/SoundMenu.layout"

User avatar
Viper
Just popping in
Just popping in
Posts: 16
Joined: Mon Aug 29, 2005 01:27
Location: US
Contact:

Re: Problem with a slider

Postby Viper » Mon Aug 29, 2005 21:43

Okay, here it is:

Code: Select all

<?xml version="1.0" ?>
<GUILayout>
   <Window Type="DefaultWindow" Name="MainMenu">
      <Window Type="TaharezLook/FrameWindow" Name="TopLevel">
         <Property Name="AbsoluteRect" Value="l:223.000000 t:67.000000 r:456.000000 b:382.000000" />
         <Property Name="Alpha" Value="0.600000" />
         <Property Name="CloseButtonEnabled" Value="False" />
         <Property Name="RelativeRect" Value="l:0.347812 t:0.139583 r:0.711875 b:0.795834" />
         <Property Name="SizingEnabled" Value="False" />
         <Property Name="Text" Value="Sound Options" />
         <Window Type="TaharezLook/Button" Name="btnQuit">
            <Property Name="AbsoluteRect" Value="l:37.000000 t:254.000000 r:203.000000 b:283.000000" />
            <Property Name="RelativeRect" Value="l:0.160624 t:0.807500 r:0.871562 b:0.897083" />
            <Property Name="Text" Value="OK" />
            </Window>
         <Window Type="TaharezLook/StaticText" Name="">
            <Property Name="AbsoluteRect" Value="l:13.000000 t:33.000000 r:118.000000 b:59.000000" />
            <Property Name="RelativeRect" Value="l:0.055938 t:0.104583 r:0.507500 b:0.187917" />
            <Property Name="Text" Value="Sound Volume" />
            </Window>
         <Window Type="TaharezLook/SliderThumb" Name="sldSound">
            <Property Name="AbsoluteRect" Value="l:7.000000 t:69.000000 r:226.000000 b:105.000000" />
            <Property Name="InheritsAlpha" Value="False" />
            <Property Name="RelativeRect" Value="l:0.028750 t:0.217917 r:0.969374 b:0.332500" />
            <Property Name="Text" Value="S" />
            </Window>
         <Window Type="TaharezLook/StaticText" Name="6">
            <Property Name="AbsoluteRect" Value="l:15.000000 t:114.000000 r:120.000000 b:141.000000" />
            <Property Name="RelativeRect" Value="l:0.063750 t:0.362916 r:0.515312 b:0.446249" />
            <Property Name="Text" Value="Music Volume" />
            </Window>
         <Window Type="TaharezLook/SliderThumb" Name="sldMusic">
            <Property Name="AbsoluteRect" Value="l:9.000000 t:149.000000 r:228.000000 b:185.000000" />
            <Property Name="InheritsAlpha" Value="False" />
            <Property Name="RelativeRect" Value="l:0.036563 t:0.472084 r:0.977187 b:0.586668" />
            <Property Name="Text" Value="S" />
            </Window>
         </Window>
      </Window>
</GUILayout>


I created it using scriptkid's layout editor, so it should have the correct syntax. Maybe I'm doing something wrong concerning the type of slider?

User avatar
Viper
Just popping in
Just popping in
Posts: 16
Joined: Mon Aug 29, 2005 01:27
Location: US
Contact:

Re: Problem with a slider

Postby Viper » Mon Aug 29, 2005 22:36

Never mind. How stupid can I be?

Changed it to:

Code: Select all

<?xml version="1.0" ?>
<GUILayout>
   <Window Type="DefaultWindow" Name="MainMenu">
      <Window Type="TaharezLook/FrameWindow" Name="TopLevel">
         <Property Name="AbsoluteRect" Value="l:292.000000 t:81.000000 r:622.000000 b:475.000000" />
         <Property Name="Alpha" Value="0.600000" />
         <Property Name="CloseButtonEnabled" Value="False" />
         <Property Name="RelativeRect" Value="l:0.365312 t:0.134583 r:0.776875 b:0.790834" />
         <Property Name="SizingEnabled" Value="False" />
         <Property Name="Text" Value="Sound Options" />
         <Window Type="TaharezLook/Button" Name="btnQuit">
            <Property Name="AbsoluteRect" Value="l:53.000000 t:334.000000 r:287.000000 b:369.000000" />
            <Property Name="RelativeRect" Value="l:0.159374 t:0.847500 r:0.870312 b:0.937083" />
            <Property Name="Text" Value="OK" />
            </Window>
         <Window Type="TaharezLook/StaticText" Name="">
            <Property Name="AbsoluteRect" Value="l:27.000000 t:41.000000 r:143.000000 b:73.000000" />
            <Property Name="RelativeRect" Value="l:0.080938 t:0.102916 r:0.433750 b:0.186250" />
            <Property Name="Text" Value="Sound Volume" />
            </Window>
         <Window Type="TaharezLook/StaticText" Name="6">
            <Property Name="AbsoluteRect" Value="l:186.000000 t:41.000000 r:297.000000 b:73.000000" />
            <Property Name="RelativeRect" Value="l:0.562500 t:0.102916 r:0.899063 b:0.186249" />
            <Property Name="Text" Value="Music Volume" />
            </Window>
         <Window Type="TaharezLook/Slider" Name="sldSound">
            <Property Name="AbsoluteRect" Value="l:60.000000 t:88.000000 r:111.000000 b:310.000000" />
            <Property Name="RelativeRect" Value="l:0.182500 t:0.223333 r:0.337500 b:0.786666" />
            </Window>
         <Window Type="TaharezLook/Slider" Name="sldMusic">
            <Property Name="AbsoluteRect" Value="l:212.000000 t:85.000000 r:263.000000 b:311.000000" />
            <Property Name="RelativeRect" Value="l:0.642501 t:0.216667 r:0.796251 b:0.788333" />
            </Window>
         </Window>
      </Window>
</GUILayout>


It works like a charm when you actually create a real slider, rather than a thumb for a slider!

User avatar
gcarlton
Just can't stay away
Just can't stay away
Posts: 149
Joined: Wed Jan 12, 2005 12:06

Re: Problem with a slider

Postby gcarlton » Tue Aug 30, 2005 03:19

It happens! I spent a day going crazy before I realised I was using scrollbar and slider interchangably. Since the interface is similar, it even half works, you just get really wierd virtual function call crashes.

On this point: Currently dynamic_cast seems to be disabled. Is it disabled deliberately throughout CEGUI or is it a strangeness in my environment? If this is deliberately disabled to avoid the RTTI hit (fair enough), perhaps there is a way to at least assert in debug for these casts.

:?

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

Re: Problem with a slider

Postby CrazyEddie » Tue Aug 30, 2005 08:54

gcarlton wrote:
On this point: Currently dynamic_cast seems to be disabled. Is it disabled deliberately throughout CEGUI or is it a strangeness in my environment? If this is deliberately disabled to avoid the RTTI hit (fair enough), perhaps there is a way to at least assert in debug for these casts.

:?


Many people do not like RTTI for whatever reason. I have nothing against it, especially not in a project like this, however CEGUI was designed not to use it, and so it is disabled within CEGUI by default.

The assert in debug mode is a valid suggestion, and is what wxWidgets does. Basically achieved by defining a cast macro which uses dynamic_cast in debug mode and static_cast in release.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 7 guests