GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 20-Jan-2009, 05:45
Newhunter Newhunter is offline
Awaiting Email Confirmation
 
Join Date: Jan 2009
Location: Rio de Janeiro, Brasil
Posts: 11
Newhunter will become famous soon enough

Problems in obtain the Input value of Fl_Float_Input class


Hi! I am with a problem, I am unable to obtain the value of a Fl_Float_Input, the object appears correctly in the window but when I try to catch the value of the object of the class Fl_Float_Input it seems that the pointer is with problems. I am using Microsoft Visual Studio 2005 and the problem that appears is "Unhandled exception at 0x1022faec (msvcr80d.dll) in Project.exe: 0xC0000005: Access violation reading location 0xfeeefeee." and the program breaks.

He is the .h and the .cpp of this class:

CPP / C++ / C Code:
#ifndef WINDOWDOSADORCLASS_H
#define WINDOWDOSADORCLASS_H

#include "MainWindow.h"

class WindowDosadorClass {
public:
	Fl_Window* Dosador();
private:
	Fl_Window* Window_Dosador;
	Fl_Float_Input *Input_Alcool;
    Fl_Float_Input *Input_Catalizador;
	Fl_Return_Button* Bt_ok;
	static void Button_OK_Dosador_cb(Fl_Widget* w, void* v);
    static void Button_Cancelar_Dosador_cb(Fl_Widget* w, void* v);
	void CriarDosador_UI();  
	double alc;
        double cat;
};

#endif

CPP / C++ / C Code:
#include "WindowDosadorClass.h"
#include <iostream>
#include <stdlib.h>


Fl_Window* WindowDosadorClass::Dosador(){
	{ Window_Dosador = new Fl_Window(250,200,340, 240, "Entrada para o Dosador");
    Window_Dosador->box(FL_GTK_UP_BOX);
    Window_Dosador->user_data((void*)(this));
     Input_Alcool = new Fl_Float_Input(150, 61, 113, 25, "Quantidade de alcool: ");
      Input_Alcool->box(FL_GTK_DOWN_BOX);
	   // Fl_Input* Input_Alcool

     Input_Catalizador = new Fl_Float_Input(180, 99, 119, 26, "Quantidade de catalizador: ");
      Input_Catalizador->box(FL_GTK_DOWN_BOX);
	   // Fl_Input* Input_Catalizador

     Bt_ok = new Fl_Return_Button(75, 175, 100, 30, "OK");
     Bt_ok->box(FL_GTK_UP_BOX);
     Bt_ok->callback(Button_OK_Dosador_cb,(void*)this);
     // Fl_Return_Button* o

    { Fl_Button* o = new Fl_Button(205, 175, 90, 30, "Cancelar");
      o->box(FL_GTK_UP_BOX);
	  o->callback(Button_Cancelar_Dosador_cb,Window_Dosador);
    } // Fl_Button* o

    { new Fl_Box(50, 10, 230, 45, "Defina as entradas para o Dosador");
    } // Fl_Box* o
	Window_Dosador->end();
	Window_Dosador->show();
	
  } // Fl_Window* Window_Dosador
  return Window_Dosador;
}


void WindowDosadorClass::Button_Cancelar_Dosador_cb(Fl_Widget* w, void* v){
	w->~Fl_Widget();
	((Fl_Window*)v)->~Fl_Window();
}
void WindowDosadorClass::CriarDosador_UI(){ //Here is the problem, all this code does not works!!
	Input_Alcool->clear_changed();
	Input_Catalizador->clear_changed();
	alc =  atof(Input_Alcool->value());  //Here the program breaks,seems like Bad Ptr 
	cat =  atof(Input_Catalizador->value());
	CriarDosador(alc,cat); //method of another class that receive the values
}
void WindowDosadorClass::Button_OK_Dosador_cb(Fl_Widget* w, void* v){
	w->~Fl_Widget();
	((WindowDosadorClass*)v)->Window_Dosador->~Fl_Window();
	((WindowDosadorClass*)v)->CriarDosador_UI(); //Call the method to 
//acess the objects Input_Alcool and Input_Catalizador of Fl_Float_Input //class
	
}

Hope someone can help me understand this stuff!!

Thanks!!
  #2  
Old 20-Feb-2009, 16:35
colagor colagor is offline
New Member
 
Join Date: Jan 2009
Posts: 5
colagor is on a distinguished road

Re: Problems in obtain the Input value of Fl_Float_Input class


i think those access violations indicate, that your code is trying to write to memory location that it has not claimed. hence it is "violating" your operating systems memory management. if it succeeded, that would be a "buffer overrun" where by it could (possibly) inject your own data or worse code into another program, or your operating system's reserved memory.

an example would be this:
CPP / C++ / C Code:
int main(void)
    {
     char dodgyArray[2];
     dodgyArray[] = "possibly malicious code"
    return 1;
    }

this is a buffer overrun because i declared the array to be two characters long and then tried to write to it much more than that.

so as far as your code is concerned, try commenting out those callbacks and see if it still does it.
I'm too much of noob so say whats wrong just by looking at it, but i got the same problem with callbacks before.
  #3  
Old 20-Feb-2009, 17:21
colagor colagor is offline
New Member
 
Join Date: Jan 2009
Posts: 5
colagor is on a distinguished road

Re: Problems in obtain the Input value of Fl_Float_Input class


sorry that code would just give an assignment error, this code would possibly give you your access violation

CPP / C++ / C Code:
int main(void)
    {
    int dodgyArray[2];
    dodgyArray[5] = 1;
    return 1;
    }
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble integrating console code into GUI Barman007 Java Forum 18 15-May-2008 13:05
Hard drive/CPU Diagnoses Issues binarybug Computer Hardware Forum 1 22-Jan-2007 19:23
Message Class TransformedBG C++ Forum 5 29-Nov-2006 21:28
C++ class -- Please help vnca_1 C++ Forum 3 14-Jun-2006 12:31
a tester class and then some. postage Java Forum 1 06-May-2006 15:48

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:17.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.