Qt 공부중인에 Qt자체의 버그인지 example의 버그인지 잘 모르겠네요..

pogusm의 이미지

첨부한 fontsampler.zip 은, Qt에 포함되어 있는 example 소스코드입니다.

첨부한 이미지에서처럼

1. 여러개의 폰트를 선택 (print preview 할 페이지가 2페이지 이상이 되도록)
2. 프린트 미리보기 실행
3. Portrait / Landscape 를 2~5회 변경 시도

를 하면 프로그램이 다운됩니다.

프린터가 없어서, 가상프린터(pdf출력)로
windows7(64bit) 와 windowsXP(32bit)에서 테스트 해봤는데 동일한 문제가 발생합니다.
(추가 : 프린터가 있는 winXP에서 테스트 해봣는데 동일한 문제가 발생합니다.)

example 소스코드를 이래저래 수정해 보았지만,
저로썬 도저히 해결책을 못찾겠습니다.

고수님들께서 한번 봐주셨으면 고맙겠습니다. 굽신굽신 ㅠㅠ

File attachments: 
첨부파일 크기
Package icon fontsampler.zip7.8 KB
Image icon fontsampler_01.png191.19 KB
shint의 이미지

가상 프린터로 xps로 잡고
페이지도 잡아보고 했는데 잘 나옵니다.
혹시 폰트'문제일지 모르니 바꿔보시는것도 괜찮아 보입니다.

윈도우7 이라서 그럴지도 모르겠네요. 관리자권한으로도 해보세요.
저는 xp 입니다.

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

pogusm의 이미지

잘 되나요? ㅠㅠ

이거참 이상하네요...

저는 1/1페이지일때는 문제가 없는데 1/8 같이 여러장일땐 win7이고 winxp(가상머신)고 둘다 에러가 나네요..

나중에 다른 컴터에서 다시 테스트 해봐야겠네요.

일부러 시간 내서 테스트 해주셔서 정말 고맙습니다. 꾸벅~

pogusm의 이미지

shint님이 이전에 한번 도와주셨었는데....

다른분께서 한번만 더 테스트 해주시면 감사하겠습니다...

프린터가 있는 winXP에서 다시 한번 테스트 해봣는데 동일한 문제가 발생합니다.

도저히 해답을, 원인을 찾을 수가 없네요.. ㅠㅠ

ps. 저는 Qt SDK를 전부 설치하지 않고...
Qt libraries 4.7.4 for Windows + Qt Creator 2.3.0 for Windows 이 두개만 설치한 환경입니다..

익명 사용자의 이미지

seg fault가 발생한 지점인데 해당 위치 자체가 문제인지 아니면
다른 부분이 잘못되어 그 영향인지는 Qt 소스를 열어보아도 잘 드러나지 않는군요.

소스와 관련된 콜 위치는 #34, #87입니다.

(Qt4.5.1, MinGW, Win-XP, GDB)

--------------------------------------------------------------------

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\user\바탕 화면\f\fontsampler\debug>gdb fontsampler.exe

GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) run
Starting program: C:\Documents and Settings\user\바탕 화면\f\fontsampler\debug/f
ontsampler.exe

(... multi page ... Landscape<->Portrait several changes ...)

Program received signal SIGSEGV, Segmentation fault.
0x6a1ad417 in QBuffer::size (this=0x755a2dc) at io/qbuffer.cpp:359
359 io/qbuffer.cpp: No such file or directory.
in io/qbuffer.cpp
Current language: auto; currently c++
(gdb) where
#0 0x6a1ad417 in QBuffer::size (this=0x755a2dc) at io/qbuffer.cpp:359
#1 0x0093d3d1 in QPicture::play (this=0x776fff0, painter=0x222e08)
at image/qpicture.cpp:422
#2 0x009cacea in QPainter::drawPicture (this=0x222e08, p=@0x2229d8,
picture=@0x776fff0) at painting/qpainter.cpp:6400
#3 0x0112bfa1 in QPainter::drawPicture (this=0x222e08, pt=@0x222c60,
p=@0x776fff0) at ../../include/QtGui/../../src/gui/painting/qpainter.h:945
#4 0x00e0d330 in (anonymous namespace)::PageItem::paint (this=0x746fed8,
painter=0x222e08, option=0x223008, widget=0x0)
at widgets/qprintpreviewwidget.cpp:105
#5 0x00f93683 in _q_paintItem (item=0x746fed8, painter=0x222e08,
option=0x223008, widget=0x0, useWindowOpacity=false,
painterStateProtection=true) at graphicsview/qgraphicsscene.cpp:4607
#6 0x00f93bdc in _q_paintIntoCache (pix=0x2233a8, item=0x746fed8,
pixmapExposed=@0x223348, itemToPixmap=@0x2231c8, renderHints=0x223368,
option=0x223008, painterStateProtection=true)
at graphicsview/qgraphicsscene.cpp:4673
#7 0x00f9604c in QGraphicsScenePrivate::drawItemHelper (this=0x5e9b130,
item=0x746fed8, painter=0x223958, option=0x5ea5468, widget=0x5369ea8,
painterStateProtection=true) at graphicsview/qgraphicsscene.cpp:4957
#8 0x00f96e79 in QGraphicsScene::drawItems (this=0x530bd50, painter=0x223958,
numItems=3, items=, options=0x5ea5468, widget=0x5369ea8)
at graphicsview/qgraphicsscene.cpp:5115
---Type to continue, or q to quit---
#9 0x00fae7d8 in QGraphicsView::drawItems (this=0x530f878, painter=0x223958,
numItems=3, items=, options=0x5ea5468)
at graphicsview/qgraphicsview.cpp:3755
#10 0x00fad7f7 in QGraphicsView::paintEvent (this=0x530f878, event=0x2241d8)
at graphicsview/qgraphicsview.cpp:3506
#11 0x008d8909 in QWidget::event (this=0x530f878, event=0x2241d8)
at kernel/qwidget.cpp:7659
#12 0x00d1fb53 in QFrame::event (this=0x530f878, e=0x2241d8)
at widgets/qframe.cpp:559
#13 0x00ddefc0 in QAbstractScrollArea::viewportEvent (this=0x530f878,
e=0x2241d8) at widgets/qabstractscrollarea.cpp:962
#14 0x00faa477 in QGraphicsView::viewportEvent (this=0x530f878, event=0x2241d8)
at graphicsview/qgraphicsview.cpp:2897
#15 0x010a1871 in QAbstractScrollAreaPrivate::viewportEvent (this=0x5e9c050,
event=0x2241d8) at widgets/qabstractscrollarea_p.h:100
#16 0x0109fd04 in QAbstractScrollAreaFilter::eventFilter (this=0x53145b0,
o=0x5369ea8, e=0x2241d8) at widgets/qabstractscrollarea_p.h:111
#17 0x6a242759 in QCoreApplicationPrivate::sendThroughObjectEventFilters (
this=0x3e5100, receiver=0x5369ea8, event=0x2241d8)
at kernel/qcoreapplication.cpp:726
#18 0x008785af in QApplicationPrivate::notify_helper (this=0x3e5100,
receiver=0x5369ea8, e=0x2241d8) at kernel/qapplication.cpp:4053
#19 0x0087844c in QApplication::notify (this=0x22fdf0, receiver=0x5369ea8,
---Type to continue, or q to quit---
e=0x2241d8) at kernel/qapplication.cpp:4022
#20 0x6a24244c in QCoreApplication::notifyInternal (this=0x22fdf0,
receiver=0x5369ea8, event=0x2241d8) at kernel/qcoreapplication.cpp:610
#21 0x0105b00c in QCoreApplication::sendSpontaneousEvent (receiver=0x5369ea8,
event=0x2241d8)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:216
#22 0x008cfd8c in QWidgetPrivate::drawWidget (this=0x5e9b008, pdev=0x7450e80,
rgn=@0x224488, offset=@0x224378, flags=68, sharedPainter=0x0,
backingStore=0x52924d8) at kernel/qwidget.cpp:5052
#23 0x00a9191e in QWidgetBackingStore::sync (this=0x52924d8)
at painting/qbackingstore.cpp:1260
#24 0x008c52da in QWidgetPrivate::syncBackingStore (this=0x5e67ad0)
at kernel/qwidget.cpp:1602
#25 0x008d8ff5 in QWidget::event (this=0x22b5cc, event=0x7569528)
at kernel/qwidget.cpp:7799
#26 0x008785d5 in QApplicationPrivate::notify_helper (this=0x3e5100,
receiver=0x22b5cc, e=0x7569528) at kernel/qapplication.cpp:4057
#27 0x0087844c in QApplication::notify (this=0x22fdf0, receiver=0x22b5cc,
e=0x7569528) at kernel/qapplication.cpp:4022
#28 0x6a24244c in QCoreApplication::notifyInternal (this=0x22fdf0,
receiver=0x22b5cc, event=0x7569528) at kernel/qcoreapplication.cpp:610
#29 0x6a2b8613 in QCoreApplication::sendEvent (receiver=0x22b5cc,
event=0x7569528)
---Type to continue, or q to quit---
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:213
#30 0x6a2435e7 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0,
event_type=0, data=0x3e51d0) at kernel/qcoreapplication.cpp:1247
#31 0x6a273466 in QEventDispatcherWin32::processEvents (this=0x3e53e0,
flags=0x226ac8) at kernel/qeventdispatcher_win.cpp:679
#32 0x008e71e8 in QGuiEventDispatcherWin32::processEvents (this=0x3e53e0,
flags=@0x226af8) at kernel/qapplication_win.cpp:1182
#33 0x6a24289e in QCoreApplication::processEvents (flags=0x226bc8)
at kernel/qcoreapplication.cpp:803
#34 0x00404211 in MainWindow::printDocument (this=0x22fd80, printer=0x22b5ec)
at mainwindow.cpp:260
#35 0x004063dd in MainWindow::qt_metacall (this=0x22fd80, _c=InvokeMetaMethod,
_id=5, _a=0x226d78) at debug/moc_mainwindow.cpp:87
#36 0x6a25e219 in QMetaObject::activate (sender=0x22b5cc,
from_signal_index=36, to_signal_index=36, argv=0x226d78)
at kernel/qobject.cpp:3111
#37 0x6a25e5f7 in QMetaObject::activate (sender=0x22b5cc, m=0x11eacf0,
local_signal_index=0, argv=0x226d78) at kernel/qobject.cpp:3185
#38 0x00e883ee in QPrintPreviewDialog::paintRequested (this=0x22b5cc,
_t1=0x22b5ec) at tmp/moc/debug_shared/moc_qprintpreviewdialog.cpp:106
#39 0x00e8828d in QPrintPreviewDialog::qt_metacall (this=0x22b5cc,
_c=InvokeMetaMethod, _id=0, _a=0x226ed8)
at tmp/moc/debug_shared/moc_qprintpreviewdialog.cpp:84
---Type to continue, or q to quit---
#40 0x6a25e219 in QMetaObject::activate (sender=0x531de18,
from_signal_index=27, to_signal_index=27, argv=0x226ed8)
at kernel/qobject.cpp:3111
#41 0x6a25e5f7 in QMetaObject::activate (sender=0x531de18, m=0x11e1174,
local_signal_index=0, argv=0x226ed8) at kernel/qobject.cpp:3185
#42 0x00e10738 in QPrintPreviewWidget::paintRequested (this=0x531de18,
_t1=0x22b5ec) at tmp/moc/debug_shared/moc_qprintpreviewwidget.cpp:136
#43 0x00e0f202 in QPrintPreviewWidgetPrivate::generatePreview (this=0x5358f60)
at widgets/qprintpreviewwidget.cpp:397
#44 0x00e1013e in QPrintPreviewWidget::setOrientation (this=0x531de18,
orientation=Portrait) at widgets/qprintpreviewwidget.cpp:605
#45 0x00e1037f in QPrintPreviewWidget::setPortraitOrientation (this=0x531de18)
at widgets/qprintpreviewwidget.cpp:755
#46 0x00e10683 in QPrintPreviewWidget::qt_metacall (this=0x531de18,
_c=InvokeMetaMethod, _id=15, _a=0x227120)
at tmp/moc/debug_shared/moc_qprintpreviewwidget.cpp:118
#47 0x6a25e219 in QMetaObject::activate (sender=0x52f0a28,
from_signal_index=5, to_signal_index=6, argv=0x227120)
at kernel/qobject.cpp:3111
#48 0x6a25e692 in QMetaObject::activate (sender=0x52f0a28, m=0x1186004,
from_local_signal_index=1, to_local_signal_index=2, argv=0x227120)
at kernel/qobject.cpp:3205
#49 0x0086887c in QAction::triggered (this=0x52f0a28, _t1=true)
---Type to continue, or q to quit---
at tmp/moc/debug_shared/moc_qaction.cpp:236
#50 0x00867b86 in QAction::activate (this=0x52f0a28, event=Trigger)
at kernel/qaction.cpp:1160
#51 0x010f78b9 in QAction::trigger (this=0x52f0a28)
at ../../include/QtGui/../../src/gui/kernel/qaction.h:203
#52 0x00dd7c40 in QToolButton::nextCheckState (this=0x536d9d0)
at widgets/qtoolbutton.cpp:1135
#53 0x00cb7994 in QAbstractButtonPrivate::click (this=0x5eb81a0)
at widgets/qabstractbutton.cpp:525
#54 0x00cb945a in QAbstractButton::mouseReleaseEvent (this=0x536d9d0,
e=0x227af8) at widgets/qabstractbutton.cpp:1115
#55 0x00dd622c in QToolButton::mouseReleaseEvent (this=0x536d9d0, e=0x227af8)
at widgets/qtoolbutton.cpp:709
#56 0x008d7ee7 in QWidget::event (this=0x536d9d0, event=0x227af8)
at kernel/qwidget.cpp:7521
#57 0x00cb930c in QAbstractButton::event (this=0x536d9d0, e=0x227af8)
at widgets/qabstractbutton.cpp:1077
#58 0x00dd7c9e in QToolButton::event (this=0x536d9d0, event=0x227af8)
at widgets/qtoolbutton.cpp:1151
#59 0x008785d5 in QApplicationPrivate::notify_helper (this=0x3e5100,
receiver=0x536d9d0, e=0x227af8) at kernel/qapplication.cpp:4057
#60 0x0087703c in QApplication::notify (this=0x22fdf0, receiver=0x536d9d0,
e=0x227af8) at kernel/qapplication.cpp:3759
---Type to continue, or q to quit---
#61 0x6a24244c in QCoreApplication::notifyInternal (this=0x22fdf0,
receiver=0x536d9d0, event=0x227af8) at kernel/qcoreapplication.cpp:610
#62 0x0105b00c in QCoreApplication::sendSpontaneousEvent (receiver=0x536d9d0,
event=0x227af8)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:216
#63 0x00875377 in QApplicationPrivate::sendMouseEvent (receiver=0x536d9d0,
event=0x227af8, alienWidget=0x536d9d0, nativeWidget=0x22b5cc,
buttonDown=0x128239c, lastMouseReceiver=@0x12823a0)
at kernel/qapplication.cpp:2925
#64 0x008eed7f in QETWidget::translateMouseEvent (this=0x22b5cc, msg=@0x229378)
at kernel/qapplication_win.cpp:3250
#65 0x008e8d1f in QtWndProc (hwnd=0x80250, message=514, wParam=0,
lParam=1442020) at kernel/qapplication_win.cpp:1674
#66 0x77cf8734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
#67 0x00080250 in non-virtual thunk to MainWindow::~MainWindow() ()
#68 0x00000202 in ?? ()
#69 0x00000000 in ?? () from
#70 0x001600e4 in non-virtual thunk to MainWindow::~MainWindow() ()
#71 0x008e80ca in qt_is_translatable_mouse_event (message=9339082)
at kernel/qapplication_win.cpp:1446
#72 0x77cf8816 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
#73 0x008e80ca in qt_is_translatable_mouse_event (message=0)
at kernel/qapplication_win.cpp:1446
---Type to continue, or q to quit---
#74 0x77cf89cd in USER32!GetWindowLongW () from C:\WINDOWS\system32\user32.dll
#75 0x00000000 in ?? () from
#76 0x008e80ca in qt_is_translatable_mouse_event (message=2266572)
at kernel/qapplication_win.cpp:1446
#77 0x77cf8a10 in USER32!DispatchMessageW ()
from C:\WINDOWS\system32\user32.dll
#78 0x002295cc in non-virtual thunk to MainWindow::~MainWindow() ()
#79 0x00000000 in ?? () from
#80 0x0022b344 in non-virtual thunk to MainWindow::~MainWindow() ()
#81 0x6a273af9 in QEventDispatcherWin32::processEvents (this=0x2295cc,
flags=0x2295cc) at kernel/qeventdispatcher_win.cpp:747
#82 0x6a273af9 in QEventDispatcherWin32::processEvents (this=0x3e53e0,
flags=0x22b36c) at kernel/qeventdispatcher_win.cpp:747
#83 0x008e71e8 in QGuiEventDispatcherWin32::processEvents (this=0x3e53e0,
flags=@0x22b3ac) at kernel/qapplication_win.cpp:1182
#84 0x6a23f5da in QEventLoop::processEvents (this=0x22b50c, flags=0x22b44c)
at kernel/qeventloop.cpp:149
#85 0x6a23f75c in QEventLoop::exec (this=0x22b50c, flags=0x22b4ec)
at kernel/qeventloop.cpp:200
#86 0x00e2ac1e in QDialog::exec (this=0x22b5cc) at dialogs/qdialog.cpp:498
#87 0x0040453f in MainWindow::on_printPreviewAction_triggered (this=0x22fd80)
at mainwindow.cpp:283
#88 0x004063af in MainWindow::qt_metacall (this=0x22fd80, _c=InvokeMetaMethod,
---Type to continue, or q to quit---
_id=3, _a=0x22b784) at debug/moc_mainwindow.cpp:85
#89 0x6a25e219 in QMetaObject::activate (sender=0x3ecbb8, from_signal_index=5,
to_signal_index=6, argv=0x22b784) at kernel/qobject.cpp:3111
#90 0x6a25e692 in QMetaObject::activate (sender=0x3ecbb8, m=0x1186004,
from_local_signal_index=1, to_local_signal_index=2, argv=0x22b784)
at kernel/qobject.cpp:3205
#91 0x0086887c in QAction::triggered (this=0x3ecbb8, _t1=false)
at tmp/moc/debug_shared/moc_qaction.cpp:236
#92 0x00867b86 in QAction::activate (this=0x3ecbb8, event=Trigger)
at kernel/qaction.cpp:1160
#93 0x00d75ddc in QMenuPrivate::activateCausedStack (this=0x52c00e8,
causedStack=@0x22b8fc, action=0x3ecbb8, action_e=Trigger, self=true)
at widgets/qmenu.cpp:967
#94 0x00d7634e in QMenuPrivate::activateAction (this=0x52c00e8,
action=0x3ecbb8, action_e=Trigger, self=true) at widgets/qmenu.cpp:1060
#95 0x00d7ba2a in QMenu::mouseReleaseEvent (this=0x52c00b8, e=0x22c2bc)
at widgets/qmenu.cpp:2254
#96 0x008d7ee7 in QWidget::event (this=0x52c00b8, event=0x22c2bc)
at kernel/qwidget.cpp:7521
#97 0x00d7c1c7 in QMenu::event (this=0x52c00b8, e=0x22c2bc)
at widgets/qmenu.cpp:2353
#98 0x008785d5 in QApplicationPrivate::notify_helper (this=0x3e5100,
receiver=0x52c00b8, e=0x22c2bc) at kernel/qapplication.cpp:4057
---Type to continue, or q to quit---
#99 0x0087703c in QApplication::notify (this=0x22fdf0, receiver=0x52c00b8,
e=0x22c2bc) at kernel/qapplication.cpp:3759
#100 0x6a24244c in QCoreApplication::notifyInternal (this=0x22fdf0,
receiver=0x52c00b8, event=0x22c2bc) at kernel/qcoreapplication.cpp:610
#101 0x0105b00c in QCoreApplication::sendSpontaneousEvent (receiver=0x52c00b8,
event=0x22c2bc)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:216
#102 0x00875377 in QApplicationPrivate::sendMouseEvent (receiver=0x52c00b8,
event=0x22c2bc, alienWidget=0x0, nativeWidget=0x52c00b8,
buttonDown=0x128239c, lastMouseReceiver=@0x12823a0)
at kernel/qapplication.cpp:2925
#103 0x008ee77f in QETWidget::translateMouseEvent (this=0x52c00b8,
msg=@0x22db3c) at kernel/qapplication_win.cpp:3178
#104 0x008e8d1f in QtWndProc (hwnd=0xa019a, message=514, wParam=0,
lParam=786454) at kernel/qapplication_win.cpp:1674
#105 0x77cf8734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
#106 0x000a019a in non-virtual thunk to MainWindow::~MainWindow() ()
#107 0x00000202 in ?? ()
#108 0x00000000 in ?? () from
#109 0x000c0016 in non-virtual thunk to MainWindow::~MainWindow() ()
#110 0x008e80ca in qt_is_translatable_mouse_event (message=9339082)
at kernel/qapplication_win.cpp:1446
#111 0x77cf8816 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
---Type to continue, or q to quit---
#112 0x008e80ca in qt_is_translatable_mouse_event (message=0)
at kernel/qapplication_win.cpp:1446
#113 0x77cf89cd in USER32!GetWindowLongW () from C:\WINDOWS\system32\user32.dll
#114 0x00000000 in ?? () from
#115 0x008e80ca in qt_is_translatable_mouse_event (message=2284944)
at kernel/qapplication_win.cpp:1446
#116 0x77cf8a10 in USER32!DispatchMessageW ()
from C:\WINDOWS\system32\user32.dll
#117 0x0022dd90 in non-virtual thunk to MainWindow::~MainWindow() ()
#118 0x00000000 in ?? () from
#119 0x0022fb08 in non-virtual thunk to MainWindow::~MainWindow() ()
#120 0x6a273af9 in QEventDispatcherWin32::processEvents (this=0x22dd90,
flags=0x22dd90) at kernel/qeventdispatcher_win.cpp:747
#121 0x6a273af9 in QEventDispatcherWin32::processEvents (this=0x3e53e0,
flags=0x22fb30) at kernel/qeventdispatcher_win.cpp:747
#122 0x008e71e8 in QGuiEventDispatcherWin32::processEvents (this=0x3e53e0,
flags=@0x22fb70) at kernel/qapplication_win.cpp:1182
#123 0x6a23f5da in QEventLoop::processEvents (this=0x22fcd0, flags=0x22fc10)
at kernel/qeventloop.cpp:149
#124 0x6a23f75c in QEventLoop::exec (this=0x22fcd0, flags=0x22fcb0)
at kernel/qeventloop.cpp:200
#125 0x6a242b1d in QCoreApplication::exec () at kernel/qcoreapplication.cpp:888
#126 0x0087636c in QApplication::exec () at kernel/qapplication.cpp:3526
---Type to continue, or q to quit---
#127 0x00401440 in qMain (argc=1, argv=0x3e44c0) at main.cpp:50
#128 0x00406a2d in WinMain (instance=0x400000, prevInstance=0x0, cmdShow=10)
at qtmain_win.cpp:136
#129 0x004065ba in main ()
at c:/usr/local/Qt/4.5.1/include/QtCore/../../src/corelib/arch/qatomic_windo
ws.h:426
(gdb)

잠안자고 이게 뭔짓인지 ... -_-

pogusm의 이미지

제가 gdb 사용법을 몰라서 잘은 모르겠지만..

어쨌든 fontsampler 에 문제가 있는 것은 맞는거 같군요..

다만.. fontsampler 소스코드내부에서 프린트, 프린트 프리뷰 관련 부분을
전역으로 선언하거나, 동적으로 할당하거나 해서 여러가지로 시도를 해보아도 여전히 해결책을 찾지 못해서
답답하네요 ㅠㅠ

밤 늦게까지 도움 주셔서 고맙습니다.

추가 : 저도 gdb를 한번 따라해 보았는데, 결과는 조금 다른거 같네요...

(Qt 4.7.4, MinGW, Win7(64bit), GDB)

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\m>cd Desktop

C:\Users\m\Desktop>gdb fontsampler.exe
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) run
Starting program: C:\Users\m\Desktop/fontsampler.exe
[New thread 2024.0x113c]
Error: dll starting at 0x77410000 not found.
Error: dll starting at 0x77310000 not found.
Error: dll starting at 0x77410000 not found.
Error: dll starting at 0x779f0000 not found.
Error: dll starting at 0x74830000 not found.
[New thread 2024.0x10ac]
[New thread 2024.0xe28]
[New thread 2024.0xc64]
[New thread 2024.0x6f8]
Error: dll starting at 0xc0d0000 not found.
Error: dll starting at 0xc0d0000 not found.
[New thread 2024.0xec0]
[New thread 2024.0x144]
Error: dll starting at 0xf830000 not found.
Error: dll starting at 0xfa00000 not found.

(폰트를 여러개 선택한다음, print preview를 실행하여 Landscape<->Portrait 여러번 변경 시도)

Program received signal SIGSEGV, Segmentation fault.
0x6a2b1756 in QScopedPointer >::
data (this=0x8)
at ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:135
135 ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h: No such f
ile or directory.
in ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h
Current language: auto; currently c++
(gdb) where
#0 0x6a2b1756 in QScopedPointer
>::data (this=0x8)
at ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:135
#1 0x6a19b14f in qGetPtrHelper r > > (p=@0x8)
at ../../include/QtCore/../../src/corelib/global/qglobal.h:2341
#2 0x6a2be5bc in QBuffer::d_func (this=0x4) at io//qbuffer.h:99
#3 0x6a19a949 in QBuffer::size (this=0x4) at io\qbuffer.cpp:376
#4 0x00a4117a in QPicture::play (this=0xce933a0, painter=0x2859ac)
at image\qpicture.cpp:412
#5 0x00ac6c3e in QPainter::drawPicture (this=0x2859ac, p=@0x2854f0,
picture=@0xce933a0) at painting\qpainter.cpp:6852
#6 0x01106891 in QPainter::drawPicture (this=0x2859ac, pt=@0x285898,
p=@0xce933a0) at ../../include/QtGui/../../src/gui/painting/qpainter.h:993
#7 0x00e1e67f in paint (this=0xce93318, painter=0x2859ac, option=0xced9358,
widget=0x0) at widgets\qprintpreviewwidget.cpp:128
#8 0x00f4ace3 in _q_paintItem (item=0xce93318, painter=0x2859ac,
option=0xced9358, widget=0x0, useWindowOpacity=false,
painterStateProtection=true) at graphicsview\qgraphicsscene.cpp:4286
#9 0x00f4b1f7 in _q_paintIntoCache (pix=0x285d70, item=0xce93318,
pixmapExposed=@0x285ccc, itemToPixmap=@0x285b88, renderHints={i = 2},
option=0xced9358, painterStateProtection=true)
at graphicsview\qgraphicsscene.cpp:4354
#10 0x00f4ceb8 in QGraphicsScenePrivate::drawItemHelper (this=0xced9200,
item=0xce93318, painter=0x28668c, option=0xced9358, widget=0xcdc7698,
painterStateProtection=true) at graphicsview\qgraphicsscene.cpp:4692
#11 0x00f4e41c in QGraphicsScenePrivate::draw (this=0xced9200,
item=0xce93318, painter=0x28668c, viewTransform=0x2865c0,
transformPtr=0x2861e0, exposedRegion=0xcec80d0, widget=0xcdc7698,
opacity=1, effectTransform=0x0, wasDirtyParentSceneTransform=false,
drawItem=true) at graphicsview\qgraphicsscene.cpp:4964
#12 0x00f4dd7f in QGraphicsScenePrivate::drawSubtreeRecursive (
this=0xced9200, item=0xce93318, painter=0x28668c, viewTransform=0x2865c0,
exposedRegion=0xcec80d0, widget=0xcdc7698, parentOpacity=1,
effectTransform=0x0) at graphicsview\qgraphicsscene.cpp:4855
#13 0x00f4d2ff in QGraphicsScenePrivate::drawItems (this=0xced9200,
painter=0x28668c, viewTransform=0x2865c0, exposedRegion=0xcec80d0,
widget=0xcdc7698) at graphicsview\qgraphicsscene.cpp:4737
#14 0x00f6a6ea in QGraphicsView::paintEvent (this=0xcdb7648, event=0x287058)
at graphicsview\qgraphicsview.cpp:3469
#15 0x009e7281 in QWidget::event (this=0xcdb7648, event=0x287058)
at kernel\qwidget.cpp:8441
#16 0x00d6a9d4 in QFrame::event (this=0xcdb7648, e=0x287058)
at widgets\qframe.cpp:557
#17 0x00df8613 in QAbstractScrollArea::viewportEvent (this=0xcdb7648,
e=0x287058) at widgets\qabstractscrollarea.cpp:1043
#18 0x00f67d5c in QGraphicsView::viewportEvent (this=0xcdb7648,
event=0x287058) at graphicsview\qgraphicsview.cpp:2864
#19 0x0105317b in QAbstractScrollAreaPrivate::viewportEvent (this=0xcec7d80,
event=0x287058) at widgets//qabstractscrollarea_p.h:100
#20 0x01051540 in QAbstractScrollAreaFilter::eventFilter (this=0xcda2970,
o=0xcdc7698, e=0x287058) at widgets//qabstractscrollarea_p.h:116
#21 0x6a2018b9 in QCoreApplicationPrivate::sendThroughObjectEventFilters (
this=0x624838, receiver=0xcdc7698, event=0x287058)
at kernel\qcoreapplication.cpp:902
#22 0x0099bd75 in QApplicationPrivate::notify_helper (this=0x624838,
receiver=0xcdc7698, e=0x287058) at kernel\qapplication.cpp:4477
#23 0x0099bc16 in QApplication::notify (this=0x28fe68, receiver=0xcdc7698,
e=0x287058) at kernel\qapplication.cpp:4446
#24 0x6a201622 in QCoreApplication::notifyInternal (this=0x28fe68,
receiver=0xcdc7698, event=0x287058) at kernel\qcoreapplication.cpp:787
#25 0x01019476 in QCoreApplication::sendSpontaneousEvent (receiver=0xcdc7698,
event=0x287058)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218
#26 0x009dfdb0 in QWidgetPrivate::drawWidget (this=0xced90c0, pdev=0xcddec38,
rgn=@0x28723c, offset=@0x287234, flags=68, sharedPainter=0x0,
backingStore=0xce92f58) at kernel\qwidget.cpp:5528
#27 0x00b6f805 in QWidgetBackingStore::sync (this=0xce92f58)
at painting\qbackingstore.cpp:1330
#28 0x009d786e in QWidgetPrivate::syncBackingStore (this=0xce245b0)
at kernel\qwidget.cpp:1862
#29 0x009e77c9 in QWidget::event (this=0x28cd34, event=0xce95220)
at kernel\qwidget.cpp:8588
#30 0x0099bd96 in QApplicationPrivate::notify_helper (this=0x624838,
receiver=0x28cd34, e=0xce95220) at kernel\qapplication.cpp:4481
#31 0x0099bc16 in QApplication::notify (this=0x28fe68, receiver=0x28cd34,
e=0xce95220) at kernel\qapplication.cpp:4446
#32 0x6a201622 in QCoreApplication::notifyInternal (this=0x28fe68,
receiver=0x28cd34, event=0xce95220) at kernel\qcoreapplication.cpp:787
#33 0x6a268b88 in QCoreApplication::sendEvent (receiver=0x28cd34,
event=0xce95220)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#34 0x6a2026cd in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0,
event_type=0, data=0x624958) at kernel\qcoreapplication.cpp:1428
#35 0x6a224b9b in qt_internal_proc (hwnd=0xa0316, message=1025, wp=0, lp=0)
at kernel\qeventdispatcher_win.cpp:497
#36 0x758e6238 in USER32!IsDialogMessageW ()
from C:\Windows\syswow64\user32.dll
#37 0x000a0316 in ?? ()
#38 0x00000401 in ?? ()
#39 0x00000000 in ?? ()
(gdb)

익명 사용자의 이미지

#3을 보시면 QBuffer::size() 에서 문제가 되는 것은 같군요..

pogusm의 이미지

하지만 아직 해결 책을 찾지 못했습니다.

Qt로 작성된
프린트 프리뷰가 정상 작동 하는 샘플이라도 찾아볼라고 하고 있는데

쉽지가 않네요.

ㅠㅠ

어쨌든 답변 감사합니다.

pogusm의 이미지

void MainWindow::printDocument(QPrinter *printer)
{
    printer->setFromTo(1, pageMap.count());
 
    QProgressDialog progress(tr("Preparing font samples..."), tr("&Cancel"),
                             0, pageMap.count(), this);
    progress.setWindowModality(Qt::ApplicationModal);
    progress.setWindowTitle(tr("Font Sampler"));
    progress.setMinimum(printer->fromPage() - 1);
    progress.setMaximum(printer->toPage());
 
    QPainter painter;
    painter.begin(printer);
    bool firstPage = true;
 
    for (int page = printer->fromPage(); page <= printer->toPage(); ++page) {
 
        if (!firstPage)
            printer->newPage();
 
        qApp->processEvents();
        if (progress.wasCanceled())
            break;
 
        printPage(page - 1, &painter, printer);
//	progress.setValue(page); // 2페이지 이상을 print preview할때, 여백조절 또는 landscape를 하면 seg fault가 발생하는것이 이것을 주석처리 함으로써 발생하지 않게 되었다.
        firstPage = false;
    }
 
    painter.end();
}

위 소스는 mainwindow.cpp 중 문제가 되는 부분의 코드입니다.
일단 progress.setValue(page); 부분을 주석처리 함으로써, seg fault 발생은 사라졌습니다.

하지만 여전히 완벽한 해결책은 찾아내질 못했습니다..

progress.setValue(page); 를 그대로 사용하면서도 seg fault가 발생하지 않도록 하기 위해
QProgressDialog progress 를 전역으로 선언 해보기도 하고, 동적할당 해보기도 하였는데도 안되더군요..

고수님들 한번만 살펴봐 주세요 ㅠㅠ

감사합니다.

jachin의 이미지

progress 객체는 for문 바깥에 선언되어 할당받았습니다. for문이 작동하는 동안 변수 page는 printer 객체의 fromPage() 함수 결과값을 const int 값으로 할당받습니다. for문이 끝나면 page 변수는 사라지겠지요. 하지만 progress 객체는 setValue 함수로 할당받을 변수가 필요할 것입니다.

void MainWindow::printDocument(QPrinter *printer) {

printer->setFromTo(1, pageMap.count());

QProgressDialog progress(tr("Preparing font samples..."), tr("&Cancel"), 0, pageMap.count(), this);
progress.setWindowModality(Qt::ApplicationModal);
progress.setWindowTitle(tr("Font Sampler"));
progress.setMinimum(printer->fromPage() - 1);
progress.setMaximum(printer->toPage());

QPainter painter;
painter.begin(printer);
bool firstPage = true;
int page = printer->fromPage();

for (; page <= printer->toPage(); ++page) {

    if (!firstPage)
        printer->newPage();

    qApp->processEvents();
    if (progress.wasCanceled())
        break;

    printPage(page - 1, &painter, printer);
    progress.setValue(page);
    firstPage = false;
}

painter.end();

}

위의 int page; 선언을 for 문 바깥에서 초기화하여 선언해주었습니다. 테스트 해봐야 하는데, 제가 테스트 할 환경이 아니어서... 죄송합니다. (_ _) 굽슨굽슨...

pogusm의 이미지

좋은 조언 감사합니다~ 굽신굽신~

흥분해서 바로 적용해 보았는데

그런데 안타깝게도 seg fault가 발생합니다. ㅠㅠㅠㅠ

아무튼 정말 감사합니다.

jachin의 이미지

역시나 머리로 생각하는 것에는 한계가 있군요. T-T

디버거로 분석해보시지는 않으셨나요?

정말 궁금하네요... @_@

pogusm의 이미지

Qt libraries 4.8.0 for Windows (minGW 4.4, 354 MB)

오잉?

jachin의 이미지

결국 논리적으론 맞는 상황이었지만, 실제 구현되는 부분에서 지원하지 못하는 경우였군요.

종종 이런 경우가 있는 것 같습니다.

컴파일러가 달랐다면 어땠을지도 궁금해지네요...

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.