Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, December 2006
problem w/ my main() in 4.2


Message 1 in thread

I think my main is causing issues.  I just upgraded from 3.3 to 4.2. 
I'm using the Gentoo Linux ebuild.
The code below constructs my tradeview just fine, seems to seg fault on
app.setMainWidget( tradeview );
Something I missed?

int main(int argc, char* argv[])
{
        cout << "creating QApplication" << endl;
        QApplication app(argc, argv);
        trdview *tradeview = new trdview;
        cout << "trdview constructor finished" << endl;
        app.setMainWidget( tradeview );
        cout << "finished setting main widget" << endl;
        tradeview->show();
        cout << "executing app" << endl;
        return app.exec();
}

--
 [ signature omitted ] 

Message 2 in thread

On 15.12.06 14:01:00, Paul England wrote:
> I think my main is causing issues.  I just upgraded from 3.3 to 4.2. 

Which doesn't automatically build all your apps against Qt4. There's
porting needed to make a Qt3 app build with Qt4 and you have to run
Qt4's qmake at least once over your project.

> The code below constructs my tradeview just fine, seems to seg fault on
> app.setMainWidget( tradeview );
> Something I missed?

One can't say without seeing the code for the trdview. So far I don't
see anything wrong. If your app crashes, then provide a backtrace so we
can see where it crashes, this can easily be done by running it in gdb

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

Andreas:

I spent a few hours porting code from Qt3 to Qt4.  I figured it would be 
better to go through and find the differences rather than run converter 
tool (which I probably should've done).  I used qt4's qmake.  Qt3's was 
the default, but wouldn't compile.

I'll be going in tomorrow and I'll see if I can't provide more information

Paul

>On 15.12.06 14:01:00, Paul England wrote:
>  
>
>>I think my main is causing issues.  I just upgraded from 3.3 to 4.2. 
>>    
>>
>
>Which doesn't automatically build all your apps against Qt4. There's
>porting needed to make a Qt3 app build with Qt4 and you have to run
>Qt4's qmake at least once over your project.
>
>  
>
>>The code below constructs my tradeview just fine, seems to seg fault on
>>app.setMainWidget( tradeview );
>>Something I missed?
>>    
>>
>
>One can't say without seeing the code for the trdview. So far I don't
>see anything wrong. If your app crashes, then provide a backtrace so we
>can see where it crashes, this can easily be done by running it in gdb
>
>Andreas
>
>  
>

--
 [ signature omitted ] 

Message 4 in thread

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Andreas:<br>
<br>
Here's what I got when running it in gdb<br>
<br>
Program received signal SIGSEGV, Segmentation fault.<br>
[Switching to Thread -1226406224 (LWP 12810)]<br>
0xb75cf17f in QWidget::testAttribute_helper () from
/usr/lib/qt4/libQtGui.so.4<br>
<br>
Not very familiar with this<br>
<br>
Andreas Pakulat wrote:
<blockquote cite="mid20061215091842.GA31102@xxxxxxxxxxxxxxxxxxxxxxxxxxx"
 type="cite">
  <pre wrap="">On 15.12.06 14:01:00, Paul England wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">I think my main is causing issues.  I just upgraded from 3.3 to 4.2. 
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Which doesn't automatically build all your apps against Qt4. There's
porting needed to make a Qt3 app build with Qt4 and you have to run
Qt4's qmake at least once over your project.

  </pre>
  <blockquote type="cite">
    <pre wrap="">The code below constructs my tradeview just fine, seems to seg fault on
app.setMainWidget( tradeview );
Something I missed?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
One can't say without seeing the code for the trdview. So far I don't
see anything wrong. If your app crashes, then provide a backtrace so we
can see where it crashes, this can easily be done by running it in gdb

Andreas

  </pre>
</blockquote>
</body>
</html>

--
 [ signature omitted ] 

Message 5 in thread

Hi,

> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1226406224 (LWP 12810)]
> 0xb75cf17f in QWidget::testAttribute_helper () from 
> /usr/lib/qt4/libQtGui.so.4
> 
> Not very familiar with this

This is not a backtrace, you have to type "backtrace" or "bt" in GDB to 
get a backtrace.

--
 [ signature omitted ] 

Message 6 in thread

This is the detailed output from gdb.
I've run qt3to4 on everything in the project, and everything
should be up to date.  Yet, it still bombs when it tries to make the
widget visible.

I've updated my main as well

int main(int argc, char* argv[])
{
        QApplication app(argc, argv);
        trdview *tradeview = new trdview;
        tradeview->show();
        return app.exec();
}


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1225726288 (LWP 6127)]
0xb76ab646 in QWidgetPrivate::create_sys () from /usr/lib/qt4/libQtGui.so.4
(gdb) bt
#0  0xb76ab646 in QWidgetPrivate::create_sys () from
/usr/lib/qt4/libQtGui.so.4
#1  0xb767fb2f in QWidget::create () from /usr/lib/qt4/libQtGui.so.4
#2  0xb7683905 in QWidget::setVisible () from /usr/lib/qt4/libQtGui.so.4
#3  0x0804e2ce in main ()



Dimitri wrote:
> Hi,
>
>> Program received signal SIGSEGV, Segmentation fault.
>> [Switching to Thread -1226406224 (LWP 12810)]
>> 0xb75cf17f in QWidget::testAttribute_helper () from
>> /usr/lib/qt4/libQtGui.so.4
>>
>> Not very familiar with this
>
> This is not a backtrace, you have to type "backtrace" or "bt" in GDB
> to get a backtrace.
>
> -- 
> Dimitri
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>

--
 [ signature omitted ] 

Message 7 in thread

Hi,

> This is the detailed output from gdb.
> I've run qt3to4 on everything in the project, and everything
> should be up to date.  Yet, it still bombs when it tries to make the
> widget visible.

OK, so the program crashes in show() not in setMainWidget().

Does this happen if you change trdview to QLabel in teh followign piece 
of code?

> I've updated my main as well
> 
> int main(int argc, char* argv[])
> {
>         QApplication app(argc, argv);
>         trdview *tradeview = new trdview;
>         tradeview->show();
>         return app.exec();
> }

--
 [ signature omitted ] 

Message 8 in thread

>>OK, so the program crashes in show() not in setMainWidget().
>>Does this happen if you change trdview to QLabel in teh followign
piece of code?

Nope.  The following runs just fine.

int main(int argc, char* argv[])
{
        QApplication app(argc, argv);
        QLabel *tradeview = new QLabel;
        tradeview->show();
        return app.exec();
}

>>Paul, it will probably be very helpful to add "CONFIG += debug" to
your .pro file of your project, and then do a make clean and make on it
to completely recompile.
>.As well, you may want to re-emerge Qt4 with the debug use flag

I tried this, but got nothing extra in gdb, or output.  Do I need to run
gdb w/ some extra arguments?

Paul


Dimitri wrote:
> Hi,
>
>> This is the detailed output from gdb.
>> I've run qt3to4 on everything in the project, and everything
>> should be up to date.  Yet, it still bombs when it tries to make the
>> widget visible.
>
> OK, so the program crashes in show() not in setMainWidget().
>
> Does this happen if you change trdview to QLabel in teh followign
> piece of code?
>
>> I've updated my main as well
>>
>> int main(int argc, char* argv[])
>> {
>>         QApplication app(argc, argv);
>>         trdview *tradeview = new trdview;
>>         tradeview->show();
>>         return app.exec();
>> }
>
> -- 
> Dimitri
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>

--
 [ signature omitted ] 

Message 9 in thread

Hi,

>>> OK, so the program crashes in show() not in setMainWidget().
>>> Does this happen if you change trdview to QLabel in teh followign
> piece of code?
> 
> Nope.  The following runs just fine.
> 
> int main(int argc, char* argv[])
> {
>         QApplication app(argc, argv);
>         QLabel *tradeview = new QLabel;
>         tradeview->show();
>         return app.exec();
> }

Then the problem must be with trdview.

I would suggest trying the following :
1) Run your application in Valgrind.
2) Check for static objects in your code.
3) Simplify the code for trdview until it doesn't crash anymore.

--
 [ signature omitted ] 

Message 10 in thread

Dimitri:

Yes, I rebuilt Qt.
And I will probably just do #3.  The problem is indeed somewhere in the
code. :(
I'll not be able to sit down with it for a couple of weeks though. 
Perhaps I'll find some
goodies then.

Thanks for your help thus far.

Paul

Dimitri wrote:
> Hi,
>
>>>> OK, so the program crashes in show() not in setMainWidget().
>>>> Does this happen if you change trdview to QLabel in teh followign
>> piece of code?
>>
>> Nope.  The following runs just fine.
>>
>> int main(int argc, char* argv[])
>> {
>>         QApplication app(argc, argv);
>>         QLabel *tradeview = new QLabel;
>>         tradeview->show();
>>         return app.exec();
>> }
>
> Then the problem must be with trdview.
>
> I would suggest trying the following :
> 1) Run your application in Valgrind.
> 2) Check for static objects in your code.
> 3) Simplify the code for trdview until it doesn't crash anymore.
>
> -- 
> Dimitri
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>

--
 [ signature omitted ] 

Message 11 in thread

Hi,

>> .As well, you may want to re-emerge Qt4 with the debug use flag
> 
> I tried this, but got nothing extra in gdb, or output.  Do I need to run
> gdb w/ some extra arguments?

Did you rebuild Qt?

--
 [ signature omitted ] 

Message 12 in thread

>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1225726288 (LWP 6127)]
> 0xb76ab646 in QWidgetPrivate::create_sys () from /usr/lib/qt4/ 
> libQtGui.so.4
> (gdb) bt
> #0  0xb76ab646 in QWidgetPrivate::create_sys () from
> /usr/lib/qt4/libQtGui.so.4
> #1  0xb767fb2f in QWidget::create () from /usr/lib/qt4/libQtGui.so.4
> #2  0xb7683905 in QWidget::setVisible () from /usr/lib/qt4/ 
> libQtGui.so.4
> #3  0x0804e2ce in main ()
>

Paul, it will probably be very helpful to add "CONFIG += debug" to  
your .pro file of your project, and then do a make clean and make on  
it to completely recompile.

As well, you may want to re-emerge Qt4 with the debug use flag so you  
get debugging symbols in your backtrace.  It will help pinpoint the  
error much more clearly.

Caleb

--
 [ signature omitted ] 

Message 13 in thread

Hi,

>         app.setMainWidget( tradeview );

QApplication::setMainWidget() is obsolete:
	http://doc.trolltech.com/4.2/porting4.html#qapplication

Of course this function shouldn't cause crashes when used, but removing 
it may solve your immediate problem.

--
 [ signature omitted ]