473,385 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

An off-topic question

I know that this is not a C++ question, but in the hope that some other
programmer with GTKmm programming experience would come to this
newsgroup, read my message and give me a hand on this issue I am
posting the question here.I know that there is a mailing list for
GTKmm, however, the list is very slow; to a point where one feel lucky
to get a reply, what a shame.
I am trying to write a class that derives from Gtk::VBox called
Contacts; the idea is to pack every widget necessary to display and
retrieve data from the user using a one class. This class will be
passed to a Gtk::Notebook::append_page().
The class compiles just fine, but at the point where I add the
Gtk::HBox object to the Gtk::VBox derived class the program
craches/segmentation fault.

Could someone please tell me what I am doing wrong?

Here is the example:
==========
WinXP
MinGW-GCC

class Contacts : virtual public Gtk::VBox{
protected:
Gtk::HBox hbox1;
Gtk::HBox hbox2;

public:
Contacts();
virtual ~Contacts();
}; //class
jme::Contacts::Contacts(){
this->pack_start(hbox1); //Segmentation Fault
}
==============

TIA

Nov 8 '05 #1
4 1503
>this->pack_start(hbox1); //Segmentation Fault

aren't you calling pack_start on this object before "this" is
completely constructed?

G

Nov 8 '05 #2
Gr*****@nospam.com wrote:
this->pack_start(hbox1); //Segmentation Fault


aren't you calling pack_start on this object before "this" is
completely constructed?


Yes and no. The OP's code was:

class Contacts : virtual public Gtk::VBox{
protected:
Gtk::HBox hbox1;
Gtk::HBox hbox2;

public:
Contacts();
virtual ~Contacts();
}; //class

jme::Contacts::Contacts(){
this->pack_start(hbox1); //Segmentation Fault
}

At the point of the segfault, all of the bases and members of Contacts
are constructed and [this] points to the current object, so there
should be no problem using data members (e.g., hbox1) or a member
function or base-class' function (e.g. pack_start). The exception is if
pack_start() is a virtual function that is actually over-ridden by
Contacts (which is not shown in the OP). See this FAQ:
http://www.parashift.com/c++-faq-lit....html#faq-23.5
..

Also, the use of [this] seems to be unnecessary in the constructor
unless there's some funny business going on that is not evident from
the OP. The body would likely be the same if it read:

pack_start( hbox1 );

Cheers! --M

Nov 8 '05 #3
Al-Burak wrote:
I know that this is not a C++ question, but in the hope that some other
programmer with GTKmm programming experience would come to this
newsgroup, read my message and give me a hand on this issue I am
posting the question here. I know that there is a mailing list for
GTKmm, however, the list is very slow; to a point where one feel lucky
to get a reply, what a shame.
Only this time. We'll check you from now on.
I am trying to write a class that derives from Gtk::VBox called
Contacts; the idea is to pack every widget necessary to display and
retrieve data from the user using a one class. This class will be
passed to a Gtk::Notebook::append_page().
The class compiles just fine, but at the point where I add the
Gtk::HBox object to the Gtk::VBox derived class the program
craches/segmentation fault.

Could someone please tell me what I am doing wrong?

Here is the example:
==========
WinXP
MinGW-GCC

class Contacts : virtual public Gtk::VBox{
protected:
Gtk::HBox hbox1;
Gtk::HBox hbox2;

public:
Contacts();
virtual ~Contacts();
}; //class
jme::Contacts::Contacts(){
this->pack_start(hbox1); //Segmentation Fault
}
==============


This could be anything. Make sure (I don't know gtk) you are using the
library correctly, check the arguments you are passing, check your
inheritance, etc. Perhaps something is going wrong in the HBox
constructors, or in the base class.

If this appears to be correct, make sure memory allocations are done
correctly. How do you create Contacts objects? On the heap? If so, are
they correctly created/used/deleted?

I hope it's a stupid error with the library. If not, you'll probably
need a couple of days to solve the problem because this looks like
undefined behavior.

Good luck!
Jonathan

Nov 8 '05 #4
[snip[
The class compiles just fine, but at the point where I add the
Gtk::HBox object to the Gtk::VBox derived class the program
craches/segmentation fault.

[snip]

A debugger can give you more information about a crash, such as a
backtrace. valgrind's memcheck is also very useful.

Murray

Nov 10 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Frank | last post by:
Whats best : register_globals ON ? OR register_globals OFF ? I currently use: $_POST
2
by: scorp7355 | last post by:
I was wondering if there is some other way to turn autocomplete off besides using "autocomplete=off", using a meta tag or something similar. It would be great if there is some way to turn it off...
21
by: nicholas | last post by:
Although in my web.config I have <customErrors mode="off" /> I still get no detailed errors. How comes ? THX This is what I get: Server Error in '/mywebfolder'Application.
5
by: Andreas Müller | last post by:
Hi! I've been looking for a way to log off another user from Windows XP, that is to terminate his session without having to shutdown Windows. My goal is to write a service (preferrably running...
31
by: TC | last post by:
I'm looking for opinions on ways to show visitors, your links will send them off-site (to another website). The following was suggested: Look at the three links under the third paragraph:...
4
by: no_spam_for_gman | last post by:
Hi, I can turn off autocommit within the command window but I cannot figure out how to turn it off when you are in the IBM DB2 Command Line Processor. Does anybody knows how? By the way I mean...
6
by: Frank Rizzo | last post by:
I have the following situation: 1. Application X1 runs under a regular user account (this user is also the currently logged on user). 2. Application X1 kicks off Application X2 using an...
1
by: robert112 | last post by:
Hi All, I have a webpage.aspx and a webusercontrol.ascx with both of them having viewstate turned off. Then in my web user control I have got some code reading the request stream: Dim str As...
13
by: Cross | last post by:
I am developing an application that will show movies. When you wach a movie, you do not want the Power Option "Turn off monitor" to be anabled. Is there anyway to fix this from VB.net? (note that I...
0
by: scooby dooby | last post by:
Hi All, I need to write a script for windows,which has the requirements as below. 1,It should log out the particuler user from windows at a particuler time ,say 6 o'clock in the evening...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.