Skip to content

Commit

Permalink
[QMS-547] Fixed: QMS freezes on zoom when activating multi-layered on…
Browse files Browse the repository at this point in the history
…line maps
  • Loading branch information
kiozen committed Sep 16, 2023
1 parent 6301026 commit ada4ed2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
V1.XX.X
[QMS-547] Fixed: QMS freezes on zoom when activating multi-layered online maps
[QMS-622] Update BRouter setup (install from github)
[QMS-623] remove use of QTimer in brouter startup error detection
[QMS-623] remove use of QTimer in BRouter startup error detection
[QMS-630] BRouter on-the-fly routing cannot be canceled

V1.17.0
Expand Down
23 changes: 12 additions & 11 deletions src/qmapshack/map/CMapTMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,22 @@ CMapTMS::CMapTMS(const QString& filename, CMapDraw* parent) : IMapOnline(parent)

void CMapTMS::getLayers(QListWidget& list) /* override */
{
QMutexLocker lock(&mutex);

list.clear();
if (layers.size() < 2) {
if (!mutex.tryLock(100)) {
return;
}

int i = 0;
for (const layer_t& layer : qAsConst(layers)) {
QListWidgetItem* item = new QListWidgetItem(layer.title, &list);
item->setCheckState(layer.enabled ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole, i++);
}
list.clear();
if (layers.size() > 1) {
int i = 0;
for (const layer_t& layer : qAsConst(layers)) {
QListWidgetItem* item = new QListWidgetItem(layer.title, &list);
item->setCheckState(layer.enabled ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole, i++);
}

connect(&list, &QListWidget::itemChanged, this, &CMapTMS::slotLayersChanged);
connect(&list, &QListWidget::itemChanged, this, &CMapTMS::slotLayersChanged);
}
mutex.unlock();
}

void CMapTMS::saveConfig(QSettings& cfg) /* override */
Expand Down
23 changes: 12 additions & 11 deletions src/qmapshack/map/CMapWMTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,22 @@ CMapWMTS::CMapWMTS(const QString& filename, CMapDraw* parent) : IMapOnline(paren
}

void CMapWMTS::getLayers(QListWidget& list) {
QMutexLocker lock(&mutex);

list.clear();
if (layers.size() < 2) {
if (!mutex.tryLock(100)) {
return;
}

int i = 0;
for (const layer_t& layer : qAsConst(layers)) {
QListWidgetItem* item = new QListWidgetItem(layer.title, &list);
item->setCheckState(layer.enabled ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole, i++);
}
list.clear();
if (layers.size() > 1) {
int i = 0;
for (const layer_t& layer : qAsConst(layers)) {
QListWidgetItem* item = new QListWidgetItem(layer.title, &list);
item->setCheckState(layer.enabled ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole, i++);
}

connect(&list, &QListWidget::itemChanged, this, &CMapWMTS::slotLayersChanged);
connect(&list, &QListWidget::itemChanged, this, &CMapWMTS::slotLayersChanged);
}
mutex.unlock();
}

void CMapWMTS::saveConfig(QSettings& cfg) /* override */
Expand Down
15 changes: 7 additions & 8 deletions src/qmapshack/map/IMapOnline.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ class QNetworkReply;

class IMapOnline : public IMap {
Q_OBJECT
public:
IMapOnline(CMapDraw* parent);
virtual ~IMapOnline() {}

signals:
void sigQueueChanged();

protected:
struct rawHeaderItem_t {
QString name;
QString value;
};

QList<rawHeaderItem_t> rawHeaderItems;

signals:
void sigQueueChanged();

protected:
/// Mutex to control access to url queue
QRecursiveMutex mutex;
/// a queue with all tile urls to request
Expand All @@ -68,12 +71,8 @@ class IMapOnline : public IMap {

void configureCache() override;

public:
void slotQueueChanged();
void slotRequestFinished(QNetworkReply* reply);

IMapOnline(CMapDraw* parent);
virtual ~IMapOnline() {}
};

#endif // IMAPONLINE_H

0 comments on commit ada4ed2

Please sign in to comment.