当我在QWidget子类中调用self.update()时,它什么都不做,这是预期的行为(我还没有实现paintEvent)。 但是,如果我使用QtCore.QRect实例调用它,则会出现分段错误,内存损坏或X服务器错误等错误。
知道如何解决这个问题吗?
编辑:
我有时会得到这个:
X Error: BadMatch (invalid parameter attributes) 8
Major opcode: 59 (X_SetClipRectangles)
Resource id: 0x5e00044
*** glibc detected *** /usr/bin/python3: double free or corruption (out): 0x00007fd5cc001280 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x75ab6)[0x7fd5e293fab6]
/lib/x86_64-linux-gnu/libc.so.6(+0x7b3b3)[0x7fd5e29453b3]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0xf0)[0x7fd5e29459a0]
/usr/lib/libQtGui.so.4(+0x2268e9)[0x7fd5e10d08e9]
/usr/lib/libQtGui.so.4(_ZN7QRegionpLERK5QRect+0x593)[0x7fd5e1209413]
/usr/lib/libQtGui.so.4(+0x3d9ef2)[0x7fd5e1283ef2]
/usr/lib/libQtGui.so.4(_ZN7QWidget6updateERK5QRect+0x92)[0x7fd5e10bcbf2]
/usr/lib/python3/dist-packages/PyQt4/QtGui.so(+0x53ce26)[0x7fd5e20b5e26]
/usr/bin/python3(PyEval_EvalFrameEx+0x681)[0x45ba51]
/usr/bin/python3(PyEval_EvalFrameEx+0x4198)[0x45f568]
======= Memory map: ========
00400000-0066d000 r-xp 00000000 08:05 3540240 /usr/bin/python3.2mu
0086c000-0086d000 r--p 0026c000 08:05 3540240 /usr/bin/python3.2mu
0086d000-008e8000 rw-p 0026d000 08:05 3540240 /usr/bin/python3.2mu
008e8000-00906000 rw-p 00000000 00:00 0
01e91000-027de000 rw-p 00000000 00:00 0 [heap]
7fd5cc000000-7fd5cc2d7000 rw-p 00000000 00:00 0
7fd5cc2d7000-7fd5d0000000 ---p 00000000 00:00 0
7fd5d2f81000-7fd5d2f82000 ---p 00000000 00:00 0
7fd5d2f82000-7fd5d3782000 rw-p 00000000 00:00 0
7fd5d3782000-7fd5d378d000 r-xp 00000000 08:05 3410670 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd5d378d000-7fd5d398c000 ---p 0000b000 08:05 3410670 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd5d398c000-7fd5d398d000 r--p 0000a000 08:05 3410670 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd5d398d000-7fd5d398e000 rw-p 0000b000 08:05 3410670 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd5d398e000-7fd5d3998000 r-xp 00000000 08:05 3408032 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd5d3998000-7fd5d3b97000 ---p 0000a000 08:05 3408032 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd5d3b97000-7fd5d3b98000 r--p 00009000 08:05 3408032 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd5d3b98000-7fd5d3b99000 rw-p 0000a000 08:05 3408032 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd5d3b99000-7fd5d3bae000 r-xp 00000000 08:05 3408175 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd5d3bae000-7fd5d3dad000 ---p 00015000 08:05 3408175 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd5d3dad000-7fd5d3dae000 r--p 00014000 08:05 3408175 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd5d3dae000-7fd5d3daf000 rw-p 00015000 08:05 3408175 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd5d3daf000-7fd5d3db1000 rw-p 00000000 00:00 0
7fd5d3db1000-7fd5d3db8000 r-xp 00000000 08:05 3408286 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd5d3db8000-7fd5d3fb7000 ---p 00007000 08:05 3408286 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd5d3fb7000-7fd5d3fb8000 r--p 00006000 08:05 3408286 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd5d3fb8000-7fd5d3fb9000 rw-p 00007000 08:05 3408286 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd5d3fb9000-7fd5d3fbd000 r-xp 00000000 08:05 3542269 /usr/lib/kde4/plugins/imageformats/kimg_xview.so
7fd5d3fbd000-7fd5d41bd000 ---p 00004000 08:05 3542269 /usr/lib/kde4/plugins/imageformats/kimg_xview.so
7fd5d41bd000-7fd5d41be000 r--p 00004000 08:05 3542269 /usr/lib/kde4/plugins/imageformats/kimg_xview.so
7fd5d41be000-7fd5d41bf000 rw-p 00005000 08:05 3542269 /usr/lib/kde4/plugins/imageformats/kimg_xview.so
7fd5d41bf000-7fd5d41ce000 r-xp 00000000 08:05 3542266 /usr/lib/kde4/plugins/imageformats/kimg_xcf.so
7fd5d41ce000-7fd5d43ce000 ---p 0000f000 08:05 3542266 /usr/lib/kde4/plugins/imageformats/kimg_xcf.so
7fd5d43ce000-7fd5d43cf000 r--p 0000f000 08:05 3542266 /usr/lib/kde4/plugins/imageformats/kimg_xcf.so
7fd5d43cf000-7fd5d43d0000 rw-p 00010000 08:05 3542266 /usr/lib/kde4/plugins/imageformats/kimg_xcf.so
7fd5d43d0000-7fd5d43d4000 rw-p 00000000 00:00 0
7fd5d43d4000-7fd5d43d9000 r-xp 00000000 08:05 3542277 /usr/lib/kde4/plugins/imageformats/kimg_tga.so
7fd5d43d9000-7fd5d45d9000 ---p 00005000 08:05 3542277 /usr/lib/kde4/plugins/imageformats/kimg_tga.so
7fd5d45d9000-7fd5d45da000 r--p 00005000 08:05 3542277 /usr/lib/kde4/plugins/imageformats/kimg_tga.so
7fd5d45da000-7fd5d45db000 rw-p 00006000 08:05 3542277 /usr/lib/kde4/plugins/imageformats/kimg_tga.so
7fd5d45db000-7fd5d45e5000 r-xp 00000000 08:05 3542272 /usr/lib/kde4/plugins/imageformats/kimg_rgb.so
7fd5d45e5000-7fd5d47e4000 ---p 0000a000 08:05 3542272 /usr/lib/kde4/plugins/imageformats/kimg_rgb.so
7fd5d47e4000-7fd5d47e5000 r--p 00009000 08:05 3542272 /usr/lib/kde4/plugins/imageformats/kimg_rgb.so
7fd5d47e5000-7fd5d47e6000 rw-p 0000a000 08:05 3542272 /usr/lib/kde4/plugins/imageformats/kimg_rgb.so
7fd5d47e6000-7fd5d47eb000 r-xp 00000000 08:05 3542268 /usr/lib/kde4/plugins/imageformats/kimg_ras.so
7fd5d47eb000-7fd5d49eb000 ---p 00005000 08:05 3542268 /usr/lib/kde4/plugins/imageformats/kimg_ras.so
7fd5d49eb000-7fd5d49ec000 r--p 00005000 08:05 3542268 /usr/lib/kde4/plugins/imageformats/kimg_ras.so
7fd5d49ec000-7fd5d49ed000 rw-p 00006000 08:05 3542268 /usr/lib/kde4/plugins/imageformats/kimg_ras.so
7fd5d49ed000-7fd5d49f2000 r-xp 00000000 08:05 3542271 /usr/lib/kde4/plugins/imageformats/kimg_psd.so
7fd5d49f2000-7fd5d4bf1000 ---p 00005000 08:05 3542271 /usr/lib/kde4/plugins/imageformats/kimg_psd.so
7fd5d4bf1000-7fd5d4bf2000 r--p 00004000 08:05 3542271 /usr/lib/kde4/plugins/imageformats/kimg_psd.so
7fd5d4bf2000-7fd5d4bf3000 rw-p 00005000 08:05 3542271 /usr/lib/kde4/plugins/imageformats/kimg_psd.so
7fd5d4bf3000-7fd5d4bf8000 r-xp 00000000 08:05 3542276 /usr/lib/kde4/plugins/imageformats/kimg_pic.so
7fd5d4bf8000-7fd5d4df7000 ---p 00005000 08:05 3542276 /usr/lib/kde4/plugins/imageformats/kimg_pic.so
7fd5d4df7000-7fd5d4df8000 r--p 00004000 08:05 3542276 /usr/lib/kde4/plugins/imageformats/kimg_pic.so
7fd5d4df8000-7fd5d4df9000 rw-p 00005000 08:05 3542276 /usr/lib/kde4/plugins/imageformats/kimg_pic.so
7fd5d4df9000-7fd5d4e01000 r-xp 00000000 08:05 3542274 /usr/lib/kde4/plugins/imageformats/kimg_pcx.so
7fd5d4e01000-7fd5d5000000 ---p 00008000 08:05 3542274 /usr/lib/kde4/plugins/imageformats/kimg_pcx.so
7fd5d5000000-7fd5d5001000 r--p 00007000 08:05 3542274 /usr/lib/kde4/plugins/imageformats/kimg_pcx.so
7fd5d5001000-7fd5d5002000 rw-p 00008000 08:05 3542274 /usr/lib/kde4/plugins/imageformats/kimg_pcx.so
7fd5d5002000-7fd5d5051000 r-xp 00000000 08:05 3544480 /usr/lib/x86_64-linux-gnu/libjasper.so.1.0.0
7fd5d5051000-7fd5d5251000 ---p 0004f000 08:05 3544480 /usr/lib/x86_64-linux-gnu/libjasper.so.1.0.0
7fd5d5251000-7fd5d5252000 r--p 0004f000 08:05 3544480 /usr/lib/x86_64-linux-gnu/libjasper.so.1.0.0
7fd5d5252000-7fd5d5256000 rw-p 00050000 08:05 3544480 /usr/lib/x86_64-linux-gnu/libjasper.so.1.0.0
7fd5d5256000-7fd5d525d000 rw-p 00000000 00:00 0
7fd5d525d000-7fd5d5262000 r-xp 00000000 08:05 3542280 /usr/lib/kde4/plugins/imageformats/kimg_jp2.so
7fd5d5262000-7fd5d5461000 ---p 00005000 08:05 3542280 /usr/lib/kde4/plugins/imageformats/kimg_jp2.so
7fd5d5461000-7fd5d5462000 r--p 00004000 08:05 3542280 /usr/lib/kde4/plugins/imageformats/kimg_jp2.so
7fd5d5462000-7fd5d5463000 rw-p 00005000 08:05 3542280 /usr/lib/kde4/plugins/imageformats/kimg_jp2.so
7fd5d5463000-7fd5d5469000 r-xp 00000000 08:05 3551477 /usr/lib/libIlmThread.so.6.0.0
7fd5d5469000-7fd5d5668000 ---p 00006000 08:05 3551477 /usr/lib/libIlmThread.so.6.0.0
7fd5d5668000-7fd5d5669000 r--p 00005000 08:05 3551477 /usr/lib/libIlmThread.so.6.0.0
7fd5d5669000-7fd5d566a000 rw-p 00006000 08:05 3551477 /usr/lib/libIlmThread.so.6.0.0
7fd5d566a000-7fd5d566f000 r-xp 00000000 08:05 3551476 /usr/lib/libImath.so.6.0.0
7fd5d566f000-7fd5d586e000 ---p 00005000 08:05 3551476 /usr/lib/libImath.so.6.0.0
7fd5d586e000-7fd5d586f000 r--p 00004000 08:05 3551476 /usr/lib/libImath.so.6.0.0
7fd5d586f000-7fd5d5870000 rw-p 00005000 08:05 3551476 /usr/lib/libImath.so.6.0.0
7fd5d5870000-7fd5d58b2000 r-xp 00000000 08:05 3551475 /usr/lib/libHalf.so.6.0.0
7fd5d58b2000-7fd5d5ab1000 ---p 00042000 08:05 3551475 /usr/lib/libHalf.so.6.0.0
7fd5d5ab1000-7fd5d5ab2000 r--p 00041000 08:05 3551475 /usr/lib/libHalf.so.6.0.0
7fd5d5ab2000-7fd5d5ab3000 rw-p 00042000 08:05 3551475 /usr/lib/libHalf.so.6.0.0
7fd5d5ab3000-7fd5d5acf000 r-xp 00000000 08:05 3551474 /usr/lib/libIex.so.6.0.0
7fd5d5acf000-7fd5d5cce000 ---p 0001c000 08:05 3551474 /usr/lib/libIex.so.6.0.0
7fd5d5cce000-7fd5d5cd2000 r--p 0001b000 08:05 3551474 /usr/lib/libIex.so.6.0.0
7fd5d5cd2000-7fd5d5cd3000 rw-p 0001f000 08:05 3551474 /usr/lib/libIex.so.6.0.0
7fd5d5cd3000-7fd5d5d88000 r-xp 00000000 08:05 3546179 /usr/lib/libIlmImf.so.6.0.0
7fd5d5d88000-7fd5d5f87000 ---p 000b5000 08:05 3546179 /usr/lib/libIlmImf.so.6.0.0
7fd5d5f87000-7fd5d5f8a000 r--p 000b4000 08:05 3546179 /usr/lib/libIlmImf.so.6.0.0
7fd5d5f8a000-7fd5d5f8c000 rw-p 000b7000 08:05 3546179 /usr/lib/libIlmImf.so.6.0.0
7fd5d5f8c000-7fd5d5f91000 r-xp 00000000 08:05 3542278 /usr/lib/kde4/plugins/imageformats/kimg_exr.so
7fd5d5f91000-7fd5d6191000 ---p 00005000 08:05 3542278 /usr/lib/kde4/plugins/imageformats/kimg_exr.so
7fd5d6191000-7fd5d6192000 r--p 00005000 08:05 3542278 /usr/lib/kde4/plugins/imageformats/kimg_exr.so
7fd5d6192000-7fd5d6193000 rw-p 00006000 08:05 3542278 /usr/lib/kde4/plugins/imageformats/kimg_exr.so
7fd5d6193000-7fd5d619b000 r-xp 00000000 08:05 3542275 /usr/lib/kde4/plugins/imageformats/kimg_eps.so
7fd5d619b000-7fd5d639a000 ---p 00008000 08:05 3542275 /usr/lib/kde4/plugins/imageformats/kimg_eps.so
7fd5d639a000-7fd5d639b000 r--p 00007000 08:05 3542275 /usr/lib/kde4/plugins/imageformats/kimg_eps.so
7fd5d639b000-7fd5d639c000 rw-p 00008000 08:05 3542275 /usr/lib/kde4/plugins/imageformats/kimg_eps.so
7fd5d639c000-7fd5d63a3000 r-xp 00000000 08:05 3542279 /usr/lib/kde4/plugins/imageformats/kimg_dds.so
7fd5d63a3000-7fd5d65a2000 ---p 00007000 08:05 3542279 /usr/lib/kde4/plugins/imageformats/kimg_dds.so
7fd5d65a2000-7fd5d65a3000 r--p 00006000 08:05 3542279 /usr/lib/kde4/plugins/imageformats/kimg_dds.so
7fd5d65a3000-7fd5d65a4000 rw-p 00007000 08:05 3542279 /usr/lib/kde4/plugins/imageformats/kimg_dds.so
7fd5d65a4000-7fd5d65af000 r-xp 00000000 08:05 3548326 /usr/lib/x86_64-linux-gnu/libjbig.so.0.0.0
7fd5d65af000-7fd5d67af000 ---p 0000b000 08:05 3548326 /usr/lib/x86_64-linux-gnu/libjbig.so.0.0.0
7fd5d67af000-7fd5d67b2000 rw-p 0000b000 08:05 3548326 /usr/lib/x86_64-linux-gnu/libjbig.so.0.0.0
7fd5d67b2000-7fd5d6815000 r-xp 00000000 08:05 3564130 /usr/lib/x86_64-linux-gnu/libtiff.so.4.3.6
7fd5d6815000-7fd5d6a14000 ---p 00063000 08:05 3564130 /usr/lib/x86_64-linux-gnu/libtiff.so.4.3.6
7fd5d6a14000-7fd5d6a17000 r--p 00062000 08:05 3564130 /usr/lib/x86_64-linux-gnu/libtiff.so.4.3.6
7fd5d6a17000-7fd5d6a18000 rw-p 00065000 08:05 3564130 /usr/lib/x86_64-linux-gnu/libtiff.so.4.3.6
7fd5d6a18000-7fd5d6a1f000 r-xp 00000000 08:05 3675220 /usr/lib/qt4/plugins/imageformats/libqtiff.so
7fd5d6a1f000-7fd5d6c1e000 ---p 00007000 08:05 3675220 /usr/lib/qt4/plugins/imageformats/libqtiff.so
7fd5d6c1e000-7fd5d6c1f000 r--p 00006000 08:05 3675220 /usr/lib/qt4/plugins/imageformats/libqtiff.so
7fd5d6c1f000-7fd5d6c20000 rw-p 00007000 08:05 3675220 /usr/lib/qt4/plugins/imageformats/libqtiff.so
7fd5d6c20000-7fd5d6c25000 r-xp 00000000 08:05 3675099 /usr/lib/qt4/plugins/imageformats/libqsvg.so
7fd5d6c25000-7fd5d6e24000 ---p 00005000 08:05 3675099 /usr/lib/qt4/plugins/imageformats/libqsvg.so
7fd5d6e24000-7fd5d6e25000 r--p 00004000 08:05 3675099 /usr/lib/qt4/plugins/imageformats/libqsvg.so
7fd5d6e25000-7fd5d6e26000 rw-p 00005000 08:05 3675099 /usr/lib/qt4/plugins/imageformats/libqsvg.so
7fd5d6e26000-7fd5d6e5b000 r-xp 00000000 08:05 3557513 /usr/lib/liblcms.so.1.0.19
7fd5d6e5b000-7fd5d705b000 ---p 00035000 08:05 3557513 /usr/lib/liblcms.so.1.0.19
7fd5d705b000-7fd5d705c000 rw-p 00035000 08:05 3557513 /usr/lib/liblcms.so.1.0.19
7fd5d705c000-7fd5d705f000 rw-p 00000000 00:00 0
7fd5d705f000-7fd5d70e5000 r-xp 00000000 08:05 3542961 /usr/lib/x86_64-linux-gnu/libmng.so.1.1.0.10
7fd5d70e5000-7fd5d72e4000 ---p 00086000 08:05 3542961 /usr/lib/x86_64-linux-gnu/libmng.so.1.1.0.10
7fd5d72e4000-7fd5d72e9000 rw-p 00085000 08:05 3542961 /usr/lib/x86_64-linux-gnu/libmng.so.1.1.0.10
7fd5d72e9000-7fd5d72ef000 r-xp 00000000 08:05 3675225 /usr/lib/qt4/plugins/imageformats/libqmng.so
7fd5d72ef000-7fd5d74ee000 ---p 00006000 08:05 3675225 /usr/lib/qt4/plugins/imageformats/libqmng.so
7fd5d74ee000-7fd5d74ef000 r--p 00005000 08:05 3675225 /usr/lib/qt4/plugins/imageformats/libqmng.so
7fd5d74ef000-7fd5d74f0000 rw-p 00006000 08:05 3675225 /usr/lib/qt4/plugins/imageformats/libqmng.so
7fd5d74f0000-7fd5d752a000 r-xp 00000000 08:05 3540817 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.4.0
7fd5d752a000-7fd5d7729000 ---p 0003a000 08:05 3540817 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.4.0
7fd5d7729000-7fd5d772a000 rw-p 00039000 08:05 3540817 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.4.0
7fd5d772a000-7fd5d7731000 r-xp 00000000 08:05 3675227 /usr/lib/qt4/plugins/imageformats/libqjpeg.so
7fd5d7731000-7fd5d7931000 ---p 00007000 08:05 3675227 /usr/lib/qt4/plugins/imageformats/libqjpeg.so
7fd5d7931000-7fd5d7932000 r--p 00007000 08:05 3675227 /usr/lib/qt4/plugins/imageformats/libqjpeg.so
7fd5d7932000-7fd5d7933000 rw-p 00008000 08:05 3675227 /usr/lib/qt4/plugins/imageformats/libqjpeg.so
7fd5d7933000-7fd5d793a000 r-xp 00000000 08:05 3675221 /usr/lib/qt4/plugins/imageformats/libqico.so
7fd5d793a000-7fd5d7b39000 ---p 00007000 08:05 3675221 /usr/lib/qt4/plugins/imageformats/libqico.so
7fd5d7b39000-7fd5d7b3a000 r--p 00006000 08:05 3675221 /usr/lib/qt4/plugins/imageformats/libqico.so
7fd5d7b3a000-7fd5d7b3b000 rw-p 00007000 08:05 3675221 /usr/lib/qt4/plugins/imageformats/libqico.so
7fd5d7b3b000-7fd5d7b42000 r-xp 00000000 08:05 3675223 /usr/lib/qt4/plugins/imageformats/libqgif.so
7fd5d7b42000-7fd5d7d41000 ---p 00007000 08:05 3675223 /usr/lib/qt4/plugins/imageformats/libqgif.so
7fd5d7d41000-7fd5d7d42000 r--p 00006000 08:05 3675223 /usr/lib/qt4/plugins/imageformats/libqgif.so
7fd5d7d42000-7fd5d7d43000 rw-p 00007000 08:05 3675223 /usr/lib/qt4/plugins/imageformats/libqgif.so
7fd5d7d43000-7fd5d7e0a000 r-xp 00000000 08:05 3673331 /usr/lib/kde4/plugins/styles/qtcurve.so
7fd5d7e0a000-7fd5d8009000 ---p 000c7000 08:05 3673331 /usr/lib/kde4/plugins/styles/qtcurve.so
7fd5d8009000-7fd5d800d000 rw-p 000c6000 08:05 3673331 /usr/lib/kde4/plugins/styles/qtcurve.so
7fd5d800d000-7fd5d8051000 r-xp 00000000 08:05 3408274 /lib/x86_64-linux-gnu/libdbus-1.so.3.7.0
7fd5d8051000-7fd5d8251000 ---p 00044000 08:05 3408274 /lib/x86_64-linux-gnu/libdbus-1.so.3.7.0
7fd5d8251000-7fd5d8252000 r--p 00044000 08:05 3408274 /lib/x86_64-linux-gnu/libdbus-1.so.3.7.0
7fd5d8252000-7fd5d8253000 rw-p 00045000 08:05 3408274 /lib/x86_64-linux-gnu/libdbus-1.so.3.7.0Abandon
答案 0 :(得分:1)
这是很难建立的信息。
我建议调查问题,找出究竟是什么导致错误。例如,Gdb是一个能够做到这一点的优秀调试器。代码分析工具可能会指向正确的位置。
-
这种各种行为的错误的一个非常常见的原因是未初始化的指针。
示例:
MyClass * x; // not initialised
... code
x->foo(); //
此指针在创建时可以指向进程内存的任何位置,因此大部分时间解除引用它会导致不存在的内存段(即分段错误)。那么,你很幸运。
然而,有时它可能指向实际存在的东西。那些时候,任何事情都可能发生:使用指针的函数可能会将一些数据写入它认为是有效缓冲区的内容,从而对稍后访问的对象造成严重破坏。
答案 1 :(得分:0)
我不再需要使用paintEvent了,因为我现在在QPixmap上绘图(为了在两个绘画会话之间保持绘图)。