Skip to content

Commit

Permalink
Merge pull request #181 from sieren/windows-fixes-1
Browse files Browse the repository at this point in the history
0.5.6 Fixes
  • Loading branch information
sieren authored Nov 21, 2016
2 parents 349b9f8 + 4c7a2e8 commit 744ef0f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 3 additions & 1 deletion QSyncthingTray.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ SOURCES = sources/qst/main.cpp \
sources/qst/updatenotifier.cpp \
sources/contrib/qcustomplot.cpp
RESOURCES = \
resources/qsyncthing.qrc
resources/qsyncthing.qrc \
resources/qsyncthingblueanim.qrc \
resources/qsyncthingdarkanim.qrc

QT += widgets
QT += network
Expand Down
2 changes: 1 addition & 1 deletion includes/qst/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Window : public QDialog
private slots:
void updateConnectionHealth(const ConnectionStateData& state);
void onNetworkActivity(bool activity);
void setIcon(int index);
void setIcon(int index, const bool isManualSet = false);
void iconActivated(QSystemTrayIcon::ActivationReason reason);
void showWebView();
void messageClicked();
Expand Down
14 changes: 11 additions & 3 deletions sources/qst/statswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ void StatsWidget::closeEvent(QCloseEvent* event)
void StatsWidget::addConnectionPoint(const std::uint16_t& numConn)
{
using namespace std::chrono;
std::lock_guard<std::mutex> lock(mDataGuard);
std::unique_lock<std::mutex> lock(mDataGuard, std::try_to_lock);
if(!lock.owns_lock())
{
return;
}
mConnectionPoints.emplace_back(std::make_tuple(numConn, system_clock::now()));
cleanupTimeData(mConnectionPoints, std::chrono::minutes{mMaxTimeInPlotMins});
zeroMissingTimeData(mConnectionPoints);
Expand All @@ -193,7 +197,11 @@ void StatsWidget::addConnectionPoint(const std::uint16_t& numConn)

void StatsWidget::updateTrafficData(const TrafficData& traffData)
{
std::lock_guard<std::mutex> lock(mDataGuard);
std::unique_lock<std::mutex> lock(mDataGuard, std::try_to_lock);
if(!lock.owns_lock())
{
return;
}
mTrafficPoints.push_back(traffData);
cleanupTimeData(mTrafficPoints, std::chrono::minutes{mMaxTimeInPlotMins});
zeroMissingTimeData(mTrafficPoints);
Expand Down Expand Up @@ -340,11 +348,11 @@ void StatsWidget::zeroMissingTimeData(Container &vec)
};

const auto itDist = std::adjacent_find(vec.begin(), vec.end(), timeCmp);
const auto itDistEnd = std::next(itDist, 1);
if (itDist == vec.end())
{
return;
}
const auto itDistEnd = std::next(itDist, 1);
assert(itDistEnd != vec.end());
const auto& timePointStart = std::get<TimeValueTypePosition>(*itDist);
const auto& timePointEnd = std::get<TimeValueTypePosition>(*itDistEnd);
Expand Down
2 changes: 1 addition & 1 deletion sources/qst/syncconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void SyncConnector::connectionHealthReceived(QNetworkReply* reply)
auto result = mAPIHandler->getConnections(replyData);
auto traffic = mAPIHandler->getCurrentTraffic(replyData);

emit(onNetworkActivityChanged(std::get<1>(traffic) + std::get<1>(traffic) > kNetworkNoiseFloor));
emit(onNetworkActivityChanged(std::get<0>(traffic) + std::get<1>(traffic) > kNetworkNoiseFloor));
emit(onConnectionHealthChanged({result, traffic}));

reply->deleteLater();
Expand Down
7 changes: 4 additions & 3 deletions sources/qst/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


//! Layout
#define currentVersion "0.5.5rc2"
#define currentVersion "0.5.6"
#define maximumWidth 400
static const std::list<std::pair<std::string, std::string>> kIconSet(
{{":/images/syncthingBlue.png", ":/images/syncthingGrey.png"},
Expand Down Expand Up @@ -165,13 +165,13 @@ void Window::onUpdateConnState(const ConnectionState& result)

//------------------------------------------------------------------------------------//

void Window::setIcon(const int index)
void Window::setIcon(const int index, const bool isManualSet)
{
// temporary workaround as setIcon seems to leak memory
// https://bugreports.qt.io/browse/QTBUG-23658?jql=text%20~%20%22setIcon%20memory%22
// https://bugreports.qt.io/browse/QTBUG-16113?jql=text%20~%20%22setIcon%20memory%22

if (index != mLastIconIndex)
if (index != mLastIconIndex || isManualSet)
{
QIcon icon;
std::pair<std::string, std::string> iconSet = mIconMonochrome ?
Expand Down Expand Up @@ -314,6 +314,7 @@ void Window::monoChromeIconChanged(const int state)
{
mIconMonochrome = state == 2 ? true : false;
mSettings.setValue("monochromeIcon", mIconMonochrome);
setIcon(mLastIconIndex, true);
}


Expand Down

0 comments on commit 744ef0f

Please sign in to comment.