Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Ticket #107 (new defect)

Opened 9 years ago

Last modified 9 years ago

Segmentation Fault with QFont

Reported by: fennellstyle Assigned to:
Priority: blocker Version: 2.0
Keywords: Cc:

Description

I get no text drawing on buttons and while trying to run tutorial 2 I get a segmentation fault when running the application:

import qt.gui.QApplication;
import qt.gui.QFont;
import qt.gui.QPushButton;


int main(string[] args)
{
    auto app = new QApplication(args);
    auto quit = new QPushButton("Quit");

    quit.resize(74, 30);
    auto font = new QFont("Courier", 18, QFont.Bold, true);
    app.setFont(font);
    QObject.connect(quit, "clicked", app, "quit");

    quit.show();
    return app.exec();
}

compiles successfully with: dmd main.d -L-lqtdgui -L-lqtdcore -L-lQtCore -L-lQtGui

running the application causes segmentation fault. If I remove the QFont references the application runs and displays the window, however there is no text on the button.

Os and Software Versions:

Linux sean-linux 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

DMD64 D Compiler v2.054

QT_VERSION: 263938
QT_VERSION_STR: 4.7.2

Change History

08/08/11 04:17:00 changed by Anonymous

I have some more information. I compiled in debug mode using:

 dmd main.d -I/usr/local/include/d -L-L/usr/qt/4/lib -L-lqtdgui -L-lqtdcore -L-lcpp_core -L-lcpp_gui -L-lQtGui -L-lQtCore -debug -g

and ran through gdb. Tthis is gdb's output:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff62fa056 in QUtf8::convertToUnicode (chars=0x4b <Address 0x4b out of bounds>, len=18, state=0x0) at codecs/qutfcodec.cpp:175
175	codecs/qutfcodec.cpp: No such file or directory.
	in codecs/qutfcodec.cpp

Any idea why my string address is out of bounds?

10/15/11 21:24:44 changed by Anonymous

Similar problems here (no test inside the button, 2nd tutorial causes segmentation fault), except that I couldn't get the same debugging information.

One more thing, while building the qtd itself, I had to change the cmake/FindD.cmake file by adding "|DMD64" to the following line:

string(REGEX MATCH "(Digital Mars|DMD32|DMD64) D Compiler v[0-9]\\.[0-9]+" dmd_version "${d_output}")