LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-05-2012, 09:18 AM   #1
hypernova07DCh
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Rep: Reputation: Disabled
Exclamation GTK+3 - Gtk Entry - Seg Fault? - Please help! :S


Hi,

I am writing a program in C++ which creates a GTK Window and should get input from the user. (But it's not working!)

The line which is causing the problem is:
Code:
textP = gtk_entry_get_text(GTK_ENTRY(entry_name));
textP is a tempoary variable which I created for debugging.
The terminal output looks like this:
Segmentation fault (core dumped)

Process returned 139 (0x8B) execution time : 2.252 s
Press ENTER to continue.
(I am working in Code::Blocks or with g++ command line.)

Other relevent pieces of code:
Code:
GtkEntryBuffer *entry_name_buffer; // Entry buffer for user input
const gchar* textP; // The string to hold the entry text
GtkWidget *entry_name; // The entry widget which will hold the persons name

entry_name_buffer = gtk_entry_buffer_new(NULL, 0); 
entry_name = gtk_entry_new_with_buffer(entry_name_buffer);
And I want to be able to do something like:

std::string any_old_string = gtk_entry_get_text(GTK_ENTRY(entry_name));

A button calls a function which is supposed to transfer the text in the gtk entry (textbox thing) to a string which can be used elsewhere in my program.

Please help!

Thanks, Edward Bird.

Last edited by hypernova07DCh; 08-05-2012 at 09:25 AM.
 
Old 08-05-2012, 11:08 AM   #2
hypernova07DCh
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Talking Callback Functions must be static?

Ah, I think I have found the problem.

Problem:
Apparently all callback functions have to be static.
Solution: Make callback functions static.

New Problem:
Apparently static functions cannot access/modify any NON-STATIC data.
Solution: Declare all required data as static, and declare static data members ABOVE main for use.

All problems fixed!

Code:
To do these things: (examples)
   Put "static" infront of callback functions.
   Change "bool boolean_member_name" To "static bool boolean_member_name"
   Put "bool boolean_member_name" OR "bool class_name::boolean_member_name" above int main(...)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where does the gtk.entry command save the text entered by the user? adhm9009 Linux - Newbie 4 07-27-2012 08:35 AM
[SOLVED] Python: Placing a gtk.Entry() into a Toolbar MetaMan Programming 2 06-18-2011 04:34 PM
Get input from entry using Gtk? michaelinux Programming 3 05-12-2011 03:16 PM
GTK entry nAvi Programming 2 08-16-2003 11:59 AM
segmentation fault with my Gtk Application jaganmolleti Programming 1 03-18-2003 12:05 PM


All times are GMT -5. The time now is 10:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration