Page 1 of 1

Problem with a slider

Posted: Mon Aug 29, 2005 03:45
by Viper
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

Re: Problem with a slider

Posted: Mon Aug 29, 2005 08:01
by CrazyEddie
We'll need to see the layout xml for the file "Layouts/SoundMenu.layout"

Re: Problem with a slider

Posted: Mon Aug 29, 2005 21:43
by Viper
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?

Re: Problem with a slider

Posted: Mon Aug 29, 2005 22:36
by Viper
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!

Re: Problem with a slider

Posted: Tue Aug 30, 2005 03:19
by gcarlton
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.

:?

Re: Problem with a slider

Posted: Tue Aug 30, 2005 08:54
by CrazyEddie
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.