我上课的方法是:
Class Strip
带标题的:
class Strip : public QMainWindow, public ILog {
身体:
void Strip::log(const string& msg) {
ui->logFeld->append(QString::fromStdString(msg));
cout << msg << endl;
}
这是从界面实现的
struct ILog {
virtual void log(const string&) = 0;
};
来电者类
在调用类的头文件中,日志类的编号为:
public:
LoadSetup(ILog *log): log(log) {};
在函数体中调用:
log->log("Error file not found or corrupted");
问题在于cout
以及QElement仅显示:or corrupted
。
字符串的其余部分会丢失在哪里,或者更准确地说,我该如何纠正它?
Valgrind的
valgrind --leak-check=yes ./Strip > LogFile 2>&1
给出一个12k行的大输出文件。
Memcheck, a memory error detector
Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
Command: ./Strip
Invalid read of size 4
at 0x6DCD0D3: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DCF464: FcConfigFilename (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DE2A15: FcConfigParseAndLoad (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8176: FcInitLoadConfig (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8265: FcInitLoadConfigAndFonts (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8484: FcInit (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x50773D9: ??? (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.1)
by 0x50049C3: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.1)
by 0x5005283: QApplication::QApplication(int&, char**, int) (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.1)
by 0x40B275: main (in /home/magu_/Strip/Strip)
Address 0xa0f6814 is 20 bytes inside a block of size 22 alloc'd
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x6DCD02C: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DCF464: FcConfigFilename (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DE2A15: FcConfigParseAndLoad (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8176: FcInitLoadConfig (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8265: FcInitLoadConfigAndFonts (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8484: FcInit (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x50773D9: ??? (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.1)
by 0x50049C3: QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.1)
by 0x5005283: QApplication::QApplication(int&, char**, int) (in /usr/lib/x86_64-linux-gnu/libQtGui.so.4.8.1)
by 0x40B275: main (in /home/magu_/Strip/Strip)
Invalid read of size 4
at 0x6DCD0E8: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DCF464: FcConfigFilename (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DE2A15: FcConfigParseAndLoad (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DE30FD: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x8FCA6F3: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FCB950: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FC87C6: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FCA17A: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FCD75C: XML_ParseBuffer (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x6DE2B70: FcConfigParseAndLoad (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8176: FcInitLoadConfig (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8265: FcInitLoadConfigAndFonts (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
Address 0xa0fe9d0 is 16 bytes inside a block of size 18 alloc'd
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x6DCD02C: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DCF464: FcConfigFilename (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DE2A15: FcConfigParseAndLoad (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DE30FD: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x8FCA6F3: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FCB950: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FC87C6: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FCA17A: ??? (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x8FCD75C: XML_ParseBuffer (in /lib/x86_64-linux-gnu/libexpat.so.1.5.2)
by 0x6DE2B70: FcConfigParseAndLoad (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
by 0x6DD8176: FcInitLoadConfig (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.4.4)
...
LEAK SUMMARY:
definitely lost: 8,775 bytes in 44 blocks
indirectly lost: 18,528 bytes in 555 blocks
possibly lost: 462,846 bytes in 2,014 blocks
still reachable: 1,207,255 bytes in 8,462 blocks
suppressed: 0 bytes in 0 blocks
Reachable blocks (those to which a pointer was found) are not shown.
To see them, rerun with: --leak-check=full --show-reachable=yes
For counts of detected and suppressed errors, rerun with: -v
ERROR SUMMARY: 930 errors from 877 contexts (suppressed: 2 from 2)
Okey大多数错误都是来自Qt的误报,我会尝试压制这些错误并尝试修复它。
问题是无法真正理解输出。任何进一步的帮助将被批准