Moved LogDialog from heap to stack
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#include "devtoolsplugin.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
@@ -16,19 +14,18 @@
|
||||
#include "logmodel.h"
|
||||
#include "logdialog.h"
|
||||
|
||||
std::shared_ptr<LogModel> model;
|
||||
LogModel model;
|
||||
QtMessageHandler previousHandler;
|
||||
|
||||
void myMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||
{
|
||||
previousHandler(type, context, message);
|
||||
|
||||
model->log(type, context.file, context.line, context.function, context.category, message);
|
||||
model.log(type, context.file, context.line, context.function, context.category, message);
|
||||
}
|
||||
|
||||
void registerMessageHandler()
|
||||
{
|
||||
model = std::make_shared<LogModel>();
|
||||
previousHandler = qInstallMessageHandler(myMessageHandler);
|
||||
}
|
||||
|
||||
@@ -54,8 +51,10 @@ DevToolsPlugin::DevToolsPlugin(QObject *parent) :
|
||||
|
||||
void DevToolsPlugin::attachTo(MainWindow &mainWindow)
|
||||
{
|
||||
auto dialog = new LogDialog(&mainWindow);
|
||||
dialog->setModel(model.get());
|
||||
mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/devtoolsplugin/images/dev-tools.png")),
|
||||
tr("Show log"), dialog, &QWidget::show);
|
||||
tr("Show log"), &mainWindow, [&mainWindow](){
|
||||
LogDialog dialog(&mainWindow);
|
||||
dialog.setModel(&model);
|
||||
dialog.exec();
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user