[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasmate/terietor/konsolepreviewer] /: Fix seg fault
From:       Giorgos Tsiapaliokas <terietor () gmail ! com>
Date:       2012-08-16 7:46:06
Message-ID: 20120816074606.AED6CA60C9 () git ! kde ! org
[Download RAW message or body]

Git commit 650a7369f7c06e774c459773a4c1d43c0c5f2fa6 by Giorgos Tsiapaliokas.
Committed on 16/08/2012 at 09:36.
Pushed by tsiapaliwkas into branch 'terietor/konsolepreviewer'.

Fix seg fault

M  +4    -7    main.cpp
M  +18   -0    mainwindow.cpp
M  +15   -0    mainwindow.h

http://commits.kde.org/plasmate/650a7369f7c06e774c459773a4c1d43c0c5f2fa6

diff --git a/main.cpp b/main.cpp
index 720c819..298be51 100644
--- a/main.cpp
+++ b/main.cpp
@@ -15,8 +15,6 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <QPointer>
-
 #include <KDebug>
 #include <KApplication>
 #include <KAboutData>
@@ -25,15 +23,15 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "mainwindow.h"
 
-QPointer<MainWindow> mainwindow;
+MainWindowWrapper *mainwindow;
 
 void customMessageHandler(QtMsgType type, const char *msg)
 {
     if (mainwindow) {
-        mainwindow->emitSendMessage(type, msg);
+        mainwindow->mainWindow()->emitSendMessage(type, msg);
     } else {
         kDebug() << "*****************************************************";
-        kDebug() << "Plasmate has fails to set a qInstallMsgHandler!!!!!!!";
+        kDebug() << "Plasmate has failed to set a custin qInstallMsgHandler!!!!!!!";
         kDebug() << "*****************************************************";
         exit(0);
     }
@@ -66,9 +64,8 @@ int main(int argc, char *argv[])
     KCmdLineArgs::parsedArgs();
     KApplication app;
 
-    mainwindow = new MainWindow();
+    mainwindow = new MainWindowWrapper();
     qInstallMsgHandler(customMessageHandler);
-    mainwindow->show();
 
     return app.exec();
 }
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 9bf19c9..c3d2d4a 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -68,6 +68,24 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 static const int STATE_VERSION = 0;
 
+MainWindowWrapper::MainWindowWrapper(QObject *parent)
+    : QObject(parent),
+    m_mainWindow(0)
+{
+    m_mainWindow = new MainWindow();
+    m_mainWindow->show();
+}
+
+MainWindowWrapper::~MainWindowWrapper()
+{
+    delete m_mainWindow;
+}
+
+MainWindow* MainWindowWrapper::mainWindow()
+{
+    return m_mainWindow;
+}
+
 MainWindow::CentralContainer::CentralContainer(QWidget* parent)
     : QWidget(parent),
       m_curMode(Preserve),
diff --git a/mainwindow.h b/mainwindow.h
index 5169d17..4b65fd2 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -183,4 +183,19 @@ private:
     bool checkImageSize(const QSize& size);
 };
 
+class MainWindowWrapper : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    MainWindowWrapper(QObject *parent = 0);
+    ~MainWindowWrapper();
+
+    MainWindow *mainWindow();
+
+private:
+    MainWindow *m_mainWindow;
+};
+
 #endif // MAINWINDOW_H

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic