From: David Faure Date: Sun, 20 Apr 2008 22:07:44 +0000 (+0000) Subject: Fix bug with the UndoUiInterface usage: if more than one mainwindow was used, the... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/d1aaeab617d4e0372e5e93b6865d3b63ceb1d596 Fix bug with the UndoUiInterface usage: if more than one mainwindow was used, the statusbar of the wrong window could be used for displaying error messages from the undo manager. svn path=/trunk/KDE/kdebase/apps/; revision=799250 --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 4b648e988..f551232a7 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -102,10 +102,8 @@ DolphinMainWindow::DolphinMainWindow(int id) : new MainWindowAdaptor(this); QDBusConnection::sessionBus().registerObject(QString("/dolphin/MainWindow%1").arg(m_id), this); - KonqFileUndoManager::incRef(); - KonqFileUndoManager* undoManager = KonqFileUndoManager::self(); - undoManager->setUiInterface(new UndoUiInterface(this)); + undoManager->setUiInterface(new UndoUiInterface()); connect(undoManager, SIGNAL(undoAvailable(bool)), this, SLOT(slotUndoAvailable(bool))); @@ -117,7 +115,6 @@ DolphinMainWindow::DolphinMainWindow(int id) : DolphinMainWindow::~DolphinMainWindow() { - KonqFileUndoManager::decRef(); DolphinApplication::app()->removeMainWindow(this); } @@ -437,6 +434,7 @@ void DolphinMainWindow::slotUndoTextChanged(const QString& text) void DolphinMainWindow::undo() { clearStatusBar(); + KonqFileUndoManager::self()->uiInterface()->setParentWidget(this); KonqFileUndoManager::self()->undo(); } @@ -1188,11 +1186,9 @@ QString DolphinMainWindow::tabName(const KUrl& url) const return url.equals(KUrl("file:///")) ? "/" : url.fileName(); } -DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) : - KonqFileUndoManager::UiInterface(mainWin), - m_mainWin(mainWin) +DolphinMainWindow::UndoUiInterface::UndoUiInterface() : + KonqFileUndoManager::UiInterface() { - Q_ASSERT(m_mainWin != 0); } DolphinMainWindow::UndoUiInterface::~UndoUiInterface() @@ -1201,8 +1197,13 @@ DolphinMainWindow::UndoUiInterface::~UndoUiInterface() void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job) { - DolphinStatusBar* statusBar = m_mainWin->activeViewContainer()->statusBar(); - statusBar->setMessage(job->errorString(), DolphinStatusBar::Error); + DolphinMainWindow* mainWin= qobject_cast(parentWidget()); + if (mainWin) { + DolphinStatusBar* statusBar = mainWin->activeViewContainer()->statusBar(); + statusBar->setMessage(job->errorString(), DolphinStatusBar::Error); + } else { + KonqFileUndoManager::UiInterface::jobError(job); + } } #include "dolphinmainwindow.moc" diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 2f0fb9589..675b08bed 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -391,12 +391,9 @@ private: class UndoUiInterface : public KonqFileUndoManager::UiInterface { public: - UndoUiInterface(DolphinMainWindow* mainWin); + UndoUiInterface(); virtual ~UndoUiInterface(); virtual void jobError(KIO::Job* job); - - private: - DolphinMainWindow* m_mainWin; }; KNewMenu* m_newMenu;