Commit a08587f7 authored by Peter Mühlenpfordt's avatar Peter Mühlenpfordt

Use QPointer member variables in Gwenview StartHelper

Summary:
`cppcheck` complains about the never deleted local pointer variable
that creates the `Gwenview::MainWindow`.
This patch uses `QPointer` and `QScopedPointer` for `MainWindow`
and the optional `QTemporaryDir` variables to clean this.

Test Plan:
Check Gwenview's normal behaviour starting with different arguments
(none, single/multiple image/s, single/multiple directory/ies).

Reviewers: #gwenview, rkflx

Reviewed By: #gwenview, rkflx

Subscribers: rkflx

Differential Revision: https://phabricator.kde.org/D10964
parent e41d0a9b
......@@ -18,10 +18,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <config-gwenview.h>
// STL
#include <memory>
// Qt
#include <QPointer>
#include <QScopedPointer>
#include <QUrl>
#include <QTemporaryDir>
......@@ -92,22 +91,22 @@ public:
void createMainWindow()
{
Gwenview::MainWindow* window = new Gwenview::MainWindow();
mMainWindow = new Gwenview::MainWindow();
if (mUrl.isValid()) {
window->setInitialUrl(mUrl);
mMainWindow->setInitialUrl(mUrl);
} else {
window->showStartMainPage();
mMainWindow->showStartMainPage();
}
window->show();
mMainWindow->show();
if (mFullScreen) {
window->actionCollection()->action("fullscreen")->trigger();
mMainWindow->actionCollection()->action("fullscreen")->trigger();
} else {
window->show();
mMainWindow->show();
}
if (mSlideShow) {
window->startSlideShow();
mMainWindow->startSlideShow();
}
}
......@@ -115,8 +114,8 @@ private:
QUrl mUrl;
bool mFullScreen;
bool mSlideShow;
std::unique_ptr<QTemporaryDir> mMultipleUrlsDir;
std::unique_ptr<Gwenview::MainWindow> mMainWindow;
QScopedPointer<QTemporaryDir> mMultipleUrlsDir;
QPointer<Gwenview::MainWindow> mMainWindow;
};
int main(int argc, char *argv[])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment