diff options
| author | 2012-01-03 13:01:19 +0000 | |
|---|---|---|
| committer | 2012-01-03 13:01:19 +0000 | |
| commit | 1979d600fe606d776d7c7e865b2e17b9cb8be765 (patch) | |
| tree | 85700447312d9335f54e1740b67935fa99fd322d /src | |
| parent | removed #kvirc@ircnet from official support channels, haven't seen any user s... (diff) | |
| download | KVIrc-1979d600fe606d776d7c7e865b2e17b9cb8be765.tar.gz KVIrc-1979d600fe606d776d7c7e865b2e17b9cb8be765.tar.bz2 KVIrc-1979d600fe606d776d7c7e865b2e17b9cb8be765.zip | |
KviMain: ported parameters to use QString
KviApplication/KviMainWindow: unrolled a bit the shutdown sequence (both us and qt was calling QApplication::quit() when the MainWindow was deleted)
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@6014 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/KviApplication.cpp | 32 | ||||
| -rw-r--r-- | src/kvirc/kernel/KviApplication.h | 4 | ||||
| -rw-r--r-- | src/kvirc/kernel/KviMain.cpp | 75 | ||||
| -rw-r--r-- | src/kvirc/ui/KviMainWindow.cpp | 20 |
4 files changed, 52 insertions, 79 deletions
diff --git a/src/kvirc/kernel/KviApplication.cpp b/src/kvirc/kernel/KviApplication.cpp index 19122daf8..dc77f7e77 100644 --- a/src/kvirc/kernel/KviApplication.cpp +++ b/src/kvirc/kernel/KviApplication.cpp @@ -586,6 +586,8 @@ KviApplication::~KviApplication() // Another critical phase. // We shutdown our subsystems in the right order here. + Q_ASSERT(g_pActiveWindow == 0); + m_bClosingDown = true; #ifndef COMPILE_NO_IPC @@ -597,14 +599,6 @@ KviApplication::~KviApplication() if(g_pCtcpPageDialog) delete g_pCtcpPageDialog; - // if we still have a frame: kill it - if(g_pMainWindow) - delete g_pMainWindow; - g_pActiveWindow = 0; // .. but it should be already 0 anyway - - // execute pending deletes (this may still contain some UI elements) - //delete g_pGarbageCollector; - if(!m_bSetupDone) return; // killed with IPC (nothing except the m_pFrameList was created yet) @@ -1751,15 +1745,17 @@ void KviApplication::autoConnectToServers() void KviApplication::createFrame() { - if(g_pMainWindow) - qDebug("WARNING: Creating the main frame twice!"); - g_pMainWindow = new KviMainWindow(); + Q_ASSERT(g_pMainWindow == 0); + + new KviMainWindow(); + + Q_ASSERT(g_pMainWindow != 0); + g_pMainWindow->createNewConsole(true); - if(m_szExecAfterStartup.hasData()) + if(!m_szExecAfterStartup.isEmpty()) { - // FIXME, this should be a QString - KviKvsScript::run(m_szExecAfterStartup.ptr(),g_pMainWindow->firstConsole()); + KviKvsScript::run(m_szExecAfterStartup,g_pMainWindow->firstConsole()); m_szExecAfterStartup = ""; } @@ -1778,14 +1774,6 @@ void KviApplication::createFrame() g_pMainWindow->show(); } -void KviApplication::destroyFrame() -{ - m_bClosingDown=true; - if(g_pMainWindow) - g_pMainWindow->deleteLater(); - g_pActiveWindow = 0; -} - bool KviApplication::connectionExists(KviIrcConnection * pConn) { KviPointerHashTableIterator<QString,KviWindow> it(*g_pGlobalWindowDict); diff --git a/src/kvirc/kernel/KviApplication.h b/src/kvirc/kernel/KviApplication.h index f31f419d0..fe632e843 100644 --- a/src/kvirc/kernel/KviApplication.h +++ b/src/kvirc/kernel/KviApplication.h @@ -131,7 +131,7 @@ public: // setup stuff (accessed from KviMain.cpp: consider private othwerise) QString m_szConfigFile; // setup bool m_bCreateConfig; // setup - KviCString m_szExecAfterStartup; + QString m_szExecAfterStartup; bool m_bShowSplashScreen; protected: #ifdef COMPILE_KDE_SUPPORT @@ -159,7 +159,6 @@ protected: #endif QFont m_fntDefaultFont; public: - void destroyFrame(); void setup(); // THIS SHOULD BE PRIVATE! (but is accessed from KviMain.cpp) #ifdef COMPILE_KDE_SUPPORT @@ -175,6 +174,7 @@ public: bool firstTimeRun() const { return m_bFirstTimeRun; }; bool kviClosingDown() const { return m_bClosingDown; }; + void setKviClosingDown() { m_bClosingDown=true; }; inline bool supportsCompositing() { diff --git a/src/kvirc/kernel/KviMain.cpp b/src/kvirc/kernel/KviMain.cpp index 87d8c4801..8509d38be 100644 --- a/src/kvirc/kernel/KviMain.cpp +++ b/src/kvirc/kernel/KviMain.cpp @@ -63,14 +63,14 @@ typedef struct _ParseArgs bool bShowPopup; bool bShowSplashScreen; bool bExecuteCommandAndClose; - KviCString szExecCommand; - KviCString szExecRemoteCommand; + QString szExecCommand; + QString szExecRemoteCommand; } ParseArgs; int parseArgs(ParseArgs * a) { - KviCString szServer; - KviCString szPort; + QString szServer; + QString szPort; int idx; if(a->argc < 2)return KVI_ARGS_RETCODE_OK; @@ -171,7 +171,7 @@ int parseArgs(ParseArgs * a) return KVI_ARGS_RETCODE_ERROR; } p = a->argv[idx]; - if(a->szExecCommand.hasData())a->szExecCommand.append("\n"); + if(!a->szExecCommand.isEmpty())a->szExecCommand.append("\n"); a->szExecCommand.append(p); continue; } @@ -185,7 +185,7 @@ int parseArgs(ParseArgs * a) return KVI_ARGS_RETCODE_ERROR; } p = a->argv[idx]; - if(a->szExecCommand.hasData())a->szExecCommand.append("\n"); + if(!a->szExecCommand.isEmpty())a->szExecCommand.append("\n"); a->szExecCommand.append(p); a->bExecuteCommandAndClose=true; continue; @@ -200,7 +200,8 @@ int parseArgs(ParseArgs * a) return KVI_ARGS_RETCODE_ERROR; } p = a->argv[idx]; - if(a->szExecRemoteCommand.hasData())a->szExecRemoteCommand.append("\n"); + if(!a->szExecRemoteCommand.isEmpty()) + a->szExecRemoteCommand.append("\n"); a->szExecRemoteCommand.append(p); continue; } @@ -256,12 +257,8 @@ int parseArgs(ParseArgs * a) p = a->argv[idx]; if(kvi_strEqualCIN(p,"irc://",6) || kvi_strEqualCIN(p,"irc6://",7) || kvi_strEqualCIN(p,"ircs://",7) || kvi_strEqualCIN(p,"ircs6://",8)) { - KviCString tmp = QString::fromLocal8Bit(p); - a->szExecCommand ="openurl "; - tmp.replaceAll("$",""); // the urls can't contain $ signs - tmp.replaceAll(";",""); // the urls can't contain ; signs - tmp.replaceAll("%",""); // the urls can't contain % signs - a->szExecCommand.append(tmp); + a->szExecCommand = "openurl "; + a->szExecCommand.append(QString::fromLocal8Bit(p).remove(QChar('$')).remove(QChar(';')).remove(QChar('%'))); return KVI_ARGS_RETCODE_OK; } return KVI_ARGS_RETCODE_ERROR; @@ -272,13 +269,11 @@ int parseArgs(ParseArgs * a) // no dash if(kvi_strEqualCIN(p,"irc://",6) || kvi_strEqualCIN(p,"irc6://",7) || kvi_strEqualCIN(p,"ircs://",7) || kvi_strEqualCIN(p,"ircs6://",8)) { - KviCString szTmp = QString::fromLocal8Bit(p); - if(a->szExecCommand.hasData())a->szExecCommand.append('\n'); - a->szExecCommand.append("openurl "); - szTmp.replaceAll("$",""); // the urls can't contain $ signs - szTmp.replaceAll(";",""); // the urls can't contain ; signs - szTmp.replaceAll("%",""); // the urls can't contain % signs - a->szExecCommand.append(szTmp); + if(!a->szExecCommand.isEmpty()) + a->szExecCommand.append('\n'); + + a->szExecCommand = "openurl "; + a->szExecCommand.append(QString::fromLocal8Bit(p).remove(QChar('$')).remove(QChar(';')).remove(QChar('%'))); } else { QString szTmp = QString::fromLocal8Bit(p); bool bOk; @@ -290,26 +285,30 @@ int parseArgs(ParseArgs * a) QString ri = szTmp.right(4); if(KviQString::equalCI(ri,".kvs")) { - if(a->szExecCommand.hasData())a->szExecCommand.append('\n'); + if(!a->szExecCommand.isEmpty()) + a->szExecCommand.append('\n'); a->szExecCommand.append("parse \""); - szTmp.replace('$',"\\$"); - szTmp.replace('\\',"\\\\"); + szTmp.replace(QChar('$'), QString("\\$")); + szTmp.replace(QChar('\\'), QString("\\\\")); a->szExecCommand.append(szTmp); a->szExecCommand.append('"'); } else if(KviQString::equalCI(ri,".kvt")) { - if(a->szExecCommand.hasData())a->szExecCommand.append('\n'); + if(!a->szExecCommand.isEmpty()) + a->szExecCommand.append('\n'); + a->szExecCommand.append("theme.install \""); - szTmp.replace('$',"\\$"); - szTmp.replace('\\',"\\\\"); + szTmp.replace(QChar('$'), QString("\\$")); + szTmp.replace(QChar('\\'), QString("\\\\")); a->szExecCommand.append(szTmp); a->szExecCommand.append('"'); } else if(KviQString::equalCI(ri,".kva")) { - if(a->szExecCommand.hasData())a->szExecCommand.append('\n'); + if(!a->szExecCommand.isEmpty()) + a->szExecCommand.append('\n'); a->szExecCommand.append("addon.install \""); - szTmp.replace('$',"\\$"); - szTmp.replace('\\',"\\\\"); + szTmp.replace(QChar('$'), QString("\\$")); + szTmp.replace(QChar('\\'), QString("\\\\")); a->szExecCommand.append(szTmp); a->szExecCommand.append('"'); } else { @@ -320,12 +319,14 @@ int parseArgs(ParseArgs * a) } } - if(szServer.hasData()) + if(!szServer.isEmpty()) { - if(a->szExecCommand.hasData())a->szExecCommand.append('\n'); + if(!a->szExecCommand.isEmpty()) + a->szExecCommand.append('\n'); + a->szExecCommand.append("server -u "); a->szExecCommand.append(szServer); - if(szPort.hasData()) + if(!szPort.isEmpty()) { a->szExecCommand.append(' '); a->szExecCommand.append(szPort); @@ -385,10 +386,10 @@ int main(int argc, char ** argv) #endif #endif - KviCString szRemoteCommand = a.szExecCommand; - if(a.szExecRemoteCommand.hasData()) + QString szRemoteCommand = a.szExecCommand; + if(!a.szExecRemoteCommand.isEmpty()) { - if(szRemoteCommand.hasData()) + if(!szRemoteCommand.isEmpty()) { szRemoteCommand.append('\n'); } @@ -423,9 +424,9 @@ int main(int argc, char ** argv) // here we could use CreateMutex on win and semget() on linux // in order to get a shared semaphore to ensure instance unicity. - if(kvi_sendIpcMessage(szRemoteCommand.ptr())) + if(kvi_sendIpcMessage(szRemoteCommand.toLocal8Bit().data())) { - if(szRemoteCommand.isEmpty()) + if(!szRemoteCommand.isEmpty()) { KviCString szTmp(KviCString::Format,"Another KVIrc session is already running on this display and with this user id.\nUse %s -f if you want to force a new session.",argv[0]); if(a.bShowPopup) diff --git a/src/kvirc/ui/KviMainWindow.cpp b/src/kvirc/ui/KviMainWindow.cpp index 7c3198429..c602b3f56 100644 --- a/src/kvirc/ui/KviMainWindow.cpp +++ b/src/kvirc/ui/KviMainWindow.cpp @@ -96,6 +96,7 @@ KviMainWindow::KviMainWindow() : KviTalMainWindow(0,"kvirc_frame") { g_pMainWindow = this; + setAttribute(Qt::WA_DeleteOnClose); setAutoFillBackground(false); setAttribute(Qt::WA_TranslucentBackground); //disable this flag that gets enabled by qt when using Qt::WA_TranslucentBackground @@ -188,21 +189,6 @@ KviMainWindow::~KviMainWindow() saveToolBarPositions(); saveModuleExtensionToolBars(); -#if 0 - // Pragma: This shouldn't be needed any more - // The objects module must call closeWindow() internally. - // - // close all the KviKvsScriptWindowWindow to avoid a race condition - // where such a window will be free'd two times: - // the first in the frameDestructorCallback (deleted as an object instance) - // the second at the end of this function (deleted as a normal window) - for(KviWindow * wnd = m_pWinList->first();wnd;wnd = m_pWinList->next()) - { - if(wnd->inherits("KviKvsScriptWindowWindow")) - closeWindow(wnd); - } -#endif - // Call the frame destructor callback AFTER saving the toolbar positions // This is because the destructor callback kills alls the KVS objects // and thus the eventual user toolbar objects too and their position @@ -246,8 +232,6 @@ KviMainWindow::~KviMainWindow() delete m_pAccellerators; g_pMainWindow = 0; - - g_pApp->quit(); } void KviMainWindow::registerModuleExtensionToolBar(KviMexToolBar * t) @@ -881,7 +865,7 @@ void KviMainWindow::closeEvent(QCloseEvent *e) e->accept(); if(g_pApp) - g_pApp->destroyFrame(); + g_pApp->setKviClosingDown(); } void KviMainWindow::hideEvent(QHideEvent *e) |
