From 4ebd741d2bd6061dd4812adf0a89bd0cdb81023d Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 20 Jul 2017 06:58:50 +0200 Subject: Fix one crash and compile issues Don't access FileName in constructWindowTitle when we don't have a file at mCurPos. That's what crashed us randomly! Also (yes, I know, should be a separate commit) fix warnings about implicit fallthru's in switch statements. The one in SmDirModel actually was a bug, the one in tabChanged is just a nuisance. Also (again), shuffle header inclusion in SmGlobals so Xlib and QT don't clash. --- pictureviewer2.cpp | 8 +++++++- shemov.cpp | 2 ++ smdirmodel.cpp | 2 +- smglobals.cpp | 7 ++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pictureviewer2.cpp b/pictureviewer2.cpp index 965111c..98ab6b8 100644 --- a/pictureviewer2.cpp +++ b/pictureviewer2.cpp @@ -714,7 +714,13 @@ QPointF PictureViewer2::getPos(QGraphicsItem *item, int pos, const QPointF &movP } QString PictureViewer2::constructWindowTitle() const { - QString retval = QString(tr("PicViewer 2 - [%1]")).arg(mFiles.at(mCurPos).at(PicFilesModel::FileName).toString()); + QString f; + if(mCurPos < mFiles.size()){ + f = mFiles.at(mCurPos).at(PicFilesModel::FileName).toString(); + }else{ + f = tr("Oh shit..."); + } + QString retval = QString(tr("PicViewer 2 - [%1]")).arg(f); return retval; } diff --git a/shemov.cpp b/shemov.cpp index 9804e94..341cb83 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -222,6 +222,8 @@ void SheMov::tabChanged(int newTab){ case Pictures: connect(mPVSelectAllA, SIGNAL(triggered()), mPicWidget->picView(), SLOT(setPVAll())); mPicWidget->constructWindowTitle(); + setDuration(0x0, false); + break; default: setDuration(0x0, false); ;; diff --git a/smdirmodel.cpp b/smdirmodel.cpp index 0d4ca30..b6bc853 100644 --- a/smdirmodel.cpp +++ b/smdirmodel.cpp @@ -69,8 +69,8 @@ QVariant SmDirModel::data(const QModelIndex &index, int role) const{ if(fi.isFile()){ return mIcons.value("file"); } - return QVariant(); } + return QVariant(); } case Qt::ForegroundRole: if(index.column() == 0){ diff --git a/smglobals.cpp b/smglobals.cpp index 23047d1..aff8e1b 100644 --- a/smglobals.cpp +++ b/smglobals.cpp @@ -17,9 +17,6 @@ #include #include -#include -#include - #include "smglobals.h" #include "archivemodel.h" #include "mappingtablemodel.h" @@ -30,6 +27,10 @@ #include "archivecontroller.h" #include "archivebrowsermodel.h" +#include +#include + + SmGlobals *SmGlobals::mInstance = 0; SmGlobals::~SmGlobals(){ -- cgit v1.2.3-70-g09d2