Merge branch 'master' of github.com:FreeCAD/FreeCAD
This commit is contained in:
commit
617088284c
|
@ -42,9 +42,6 @@ using namespace Base;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char format[4024]; // global buffer
|
|
||||||
const unsigned int format_len = 4024;
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// Construction destruction
|
// Construction destruction
|
||||||
|
@ -171,6 +168,9 @@ bool ConsoleSingleton::IsMsgTypeEnabled(const char* sObs, FreeCAD_ConsoleMsgType
|
||||||
*/
|
*/
|
||||||
void ConsoleSingleton::Message( const char *pMsg, ... )
|
void ConsoleSingleton::Message( const char *pMsg, ... )
|
||||||
{
|
{
|
||||||
|
char format[4024];
|
||||||
|
const unsigned int format_len = 4024;
|
||||||
|
|
||||||
va_list namelessVars;
|
va_list namelessVars;
|
||||||
va_start(namelessVars, pMsg); // Get the "..." vars
|
va_start(namelessVars, pMsg); // Get the "..." vars
|
||||||
vsnprintf(format, format_len, pMsg, namelessVars);
|
vsnprintf(format, format_len, pMsg, namelessVars);
|
||||||
|
@ -195,6 +195,9 @@ void ConsoleSingleton::Message( const char *pMsg, ... )
|
||||||
*/
|
*/
|
||||||
void ConsoleSingleton::Warning( const char *pMsg, ... )
|
void ConsoleSingleton::Warning( const char *pMsg, ... )
|
||||||
{
|
{
|
||||||
|
char format[4024];
|
||||||
|
const unsigned int format_len = 4024;
|
||||||
|
|
||||||
va_list namelessVars;
|
va_list namelessVars;
|
||||||
va_start(namelessVars, pMsg); // Get the "..." vars
|
va_start(namelessVars, pMsg); // Get the "..." vars
|
||||||
vsnprintf(format, format_len, pMsg, namelessVars);
|
vsnprintf(format, format_len, pMsg, namelessVars);
|
||||||
|
@ -219,6 +222,9 @@ void ConsoleSingleton::Warning( const char *pMsg, ... )
|
||||||
*/
|
*/
|
||||||
void ConsoleSingleton::Error( const char *pMsg, ... )
|
void ConsoleSingleton::Error( const char *pMsg, ... )
|
||||||
{
|
{
|
||||||
|
char format[4024];
|
||||||
|
const unsigned int format_len = 4024;
|
||||||
|
|
||||||
va_list namelessVars;
|
va_list namelessVars;
|
||||||
va_start(namelessVars, pMsg); // Get the "..." vars
|
va_start(namelessVars, pMsg); // Get the "..." vars
|
||||||
vsnprintf(format, format_len, pMsg, namelessVars);
|
vsnprintf(format, format_len, pMsg, namelessVars);
|
||||||
|
@ -246,6 +252,9 @@ void ConsoleSingleton::Error( const char *pMsg, ... )
|
||||||
|
|
||||||
void ConsoleSingleton::Log( const char *pMsg, ... )
|
void ConsoleSingleton::Log( const char *pMsg, ... )
|
||||||
{
|
{
|
||||||
|
char format[4024];
|
||||||
|
const unsigned int format_len = 4024;
|
||||||
|
|
||||||
if (!_bVerbose)
|
if (!_bVerbose)
|
||||||
{
|
{
|
||||||
va_list namelessVars;
|
va_list namelessVars;
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
# include <QMdiSubWindow>
|
# include <QMdiSubWindow>
|
||||||
# include <QWaitCondition>
|
# include <QWaitCondition>
|
||||||
# include <QTranslator>
|
# include <QTranslator>
|
||||||
|
# include <QRunnable>
|
||||||
|
# include <QThreadPool>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Base/Console.h>
|
#include <Base/Console.h>
|
||||||
|
@ -638,6 +640,110 @@ bool CmdTestMDI3::isActive(void)
|
||||||
return getMainWindow()->activeWindow();
|
return getMainWindow()->activeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEF_STD_CMD(CmdTestConsoleOutput);
|
||||||
|
|
||||||
|
CmdTestConsoleOutput::CmdTestConsoleOutput()
|
||||||
|
: Command("Std_TestConsoleOutput")
|
||||||
|
{
|
||||||
|
sGroup = QT_TR_NOOP("Standard-Test");
|
||||||
|
sMenuText = QT_TR_NOOP("Test console output");
|
||||||
|
sToolTipText= QT_TR_NOOP("Test console output");
|
||||||
|
sStatusTip = QT_TR_NOOP("Test console output");
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Gui {
|
||||||
|
class TestConsoleObserver : public Base::ConsoleObserver
|
||||||
|
{
|
||||||
|
QMutex mutex;
|
||||||
|
public:
|
||||||
|
int matchMsg, matchWrn, matchErr, matchLog;
|
||||||
|
TestConsoleObserver() : matchMsg(0), matchWrn(0), matchErr(0), matchLog(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual void Warning(const char * msg)
|
||||||
|
{
|
||||||
|
mutex.lock();
|
||||||
|
matchWrn += strcmp(msg, "Write a warning to the console output.\n");
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
virtual void Message(const char * msg)
|
||||||
|
{
|
||||||
|
mutex.lock();
|
||||||
|
matchMsg += strcmp(msg, "Write a message to the console output.\n");
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
virtual void Error(const char * msg)
|
||||||
|
{
|
||||||
|
mutex.lock();
|
||||||
|
matchErr += strcmp(msg, "Write an error to the console output.\n");
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
virtual void Log(const char * msg)
|
||||||
|
{
|
||||||
|
mutex.lock();
|
||||||
|
matchLog += strcmp(msg, "Write a log to the console output.\n");
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConsoleMessageTask : public QRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
for (int i=0; i<10; i++)
|
||||||
|
Base::Console().Message("Write a message to the console output.\n");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConsoleWarningTask : public QRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
for (int i=0; i<10; i++)
|
||||||
|
Base::Console().Warning("Write a warning to the console output.\n");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConsoleErrorTask : public QRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
for (int i=0; i<10; i++)
|
||||||
|
Base::Console().Error("Write an error to the console output.\n");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class ConsoleLogTask : public QRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
for (int i=0; i<10; i++)
|
||||||
|
Base::Console().Log("Write a log to the console output.\n");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CmdTestConsoleOutput::activated(int iMsg)
|
||||||
|
{
|
||||||
|
TestConsoleObserver obs;
|
||||||
|
Base::Console().AttachObserver(&obs);
|
||||||
|
QThreadPool::globalInstance()->start(new ConsoleMessageTask);
|
||||||
|
QThreadPool::globalInstance()->start(new ConsoleWarningTask);
|
||||||
|
QThreadPool::globalInstance()->start(new ConsoleErrorTask);
|
||||||
|
QThreadPool::globalInstance()->start(new ConsoleLogTask);
|
||||||
|
QThreadPool::globalInstance()->waitForDone();
|
||||||
|
Base::Console().DetachObserver(&obs);
|
||||||
|
|
||||||
|
if (obs.matchMsg > 0 || obs.matchWrn > 0 || obs.matchErr > 0 || obs.matchLog > 0) {
|
||||||
|
Base::Console().Error("Race condition in Console class\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Gui {
|
namespace Gui {
|
||||||
|
|
||||||
|
@ -661,6 +767,7 @@ void CreateTestCommands(void)
|
||||||
rcCmdMgr.addCommand(new CmdTestMDI1());
|
rcCmdMgr.addCommand(new CmdTestMDI1());
|
||||||
rcCmdMgr.addCommand(new CmdTestMDI2());
|
rcCmdMgr.addCommand(new CmdTestMDI2());
|
||||||
rcCmdMgr.addCommand(new CmdTestMDI3());
|
rcCmdMgr.addCommand(new CmdTestMDI3());
|
||||||
|
rcCmdMgr.addCommand(new CmdTestConsoleOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Gui
|
} // namespace Gui
|
||||||
|
|
|
@ -37,12 +37,14 @@
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <qrect.h>
|
#include <qrect.h>
|
||||||
#include <qregexp.h>
|
#include <qregexp.h>
|
||||||
|
#include <qrunnable.h>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <qtextcodec.h>
|
#include <qtextcodec.h>
|
||||||
#include <qtextstream.h>
|
#include <qtextstream.h>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
|
#include <qthreadpool.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
#include <qtranslator.h>
|
#include <qtranslator.h>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
@ -122,7 +124,7 @@
|
||||||
#include <QStylePainter>
|
#include <QStylePainter>
|
||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
#include <qtabbar.h>
|
#include <qtabbar.h>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <qtabwidget.h>
|
#include <qtabwidget.h>
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
|
|
@ -86,6 +86,10 @@ class TestWorkbench ( Workbench ):
|
||||||
list = ["Std_TestProgress1", "Std_TestProgress2", "Std_TestProgress3", "Std_TestProgress4", "Std_TestProgress5"]
|
list = ["Std_TestProgress1", "Std_TestProgress2", "Std_TestProgress3", "Std_TestProgress4", "Std_TestProgress5"]
|
||||||
self.appendMenu(menu,list)
|
self.appendMenu(menu,list)
|
||||||
|
|
||||||
|
menu = ["Test &Commands","Console"]
|
||||||
|
list = ["Std_TestConsoleOutput"]
|
||||||
|
self.appendMenu(menu,list)
|
||||||
|
|
||||||
menu = ["Test &Commands","MDI"]
|
menu = ["Test &Commands","MDI"]
|
||||||
list = ["Std_MDITest1", "Std_MDITest2", "Std_MDITest3"]
|
list = ["Std_MDITest1", "Std_MDITest2", "Std_MDITest3"]
|
||||||
self.appendMenu(menu,list)
|
self.appendMenu(menu,list)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user