Skip to content

Commit

Permalink
Fixed #750
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenHilferink committed Jun 19, 2024
1 parent 548f0c2 commit 02832d8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
1 change: 1 addition & 0 deletions geo/dll/src/GridDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ class GridDistOperator : public Operator

latFactors.emplace_back(0.5 * factor, 0.5 * sqrt(1+factor*factor));
}
errorFrame.m_ctx = nullptr;
}

DataWriteLock resLock(res, dms_rw_mode::write_only_mustzero);
Expand Down
35 changes: 22 additions & 13 deletions qtgui/exe/src/DmsMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,9 @@ void MainWindow::tableView() {

void geoDMSContextMessage(ClientHandle clientHandle, CharPtr msg) {
assert(IsMainThread());
auto dms_main_window = reinterpret_cast<MainWindow*>(clientHandle);
dms_main_window->setStatusMessage(msg);
auto mw = MainWindow::TheOne();
if (mw)
mw->setStatusMessage(msg);
return;
}

Expand Down Expand Up @@ -1083,7 +1084,9 @@ SharedStr passed_time_str(CharPtr preFix, time_t passedTime) {
result = mySSPrintF("%s%s%02d:%02d:%02d "
, preFix
, result.c_str()
, passedTime / seconds_in_hour, (passedTime / seconds_in_hour) % seconds_in_hour, passedTime % seconds_in_minute
, passedTime / seconds_in_hour
, (passedTime / seconds_in_minute) % seconds_in_minute
, passedTime % seconds_in_minute
);
return result;
}
Expand Down Expand Up @@ -1118,14 +1121,14 @@ void MainWindow::end_timing(AbstrMsgGenerator* ach) {
if (m_processing_records.size() > 10)
m_processing_records.erase(m_processing_records.begin());

if (!top_of_records_is_changing)
return;

if (m_calculation_times_window->isVisible())
update_calculation_times_report();

assert(passedTime <= passed_time(m_processing_records.back()));
if (!top_of_records_is_changing)
return;

assert(passedTime == passed_time(m_processing_records.back()));

m_LongestProcessingRecordTxt = passed_time_str(" - max processing time: ", passedTime);

updateStatusMessage();
Expand Down Expand Up @@ -1359,8 +1362,10 @@ void MainWindow::doViewAction(TreeItem* tiContext, CharPtrRange sAction, QWidget
}

static bool s_TreeViewRefreshPending = false;
void AnyTreeItemStateHasChanged(ClientHandle clientHandle, const TreeItem* self, NotificationCode notificationCode) {
auto mainWindow = reinterpret_cast<MainWindow*>(clientHandle);
void AnyTreeItemStateHasChanged(ClientHandle /*clientHandle*/, const TreeItem* self, NotificationCode notificationCode) {
auto mainWindow = MainWindow::TheOne();
if (!mainWindow)
return;
switch (notificationCode) {
case NC_Deleting: break; // TODO: remove self from any representation to avoid accessing it's dangling pointer
case NC_Creating: break;
Expand Down Expand Up @@ -1404,15 +1409,19 @@ void AnyTreeItemStateHasChanged(ClientHandle clientHandle, const TreeItem* self,

#include "waiter.h"

void OnStartWaiting(void* clientHandle, AbstrMsgGenerator* ach) {
void OnStartWaiting(ClientHandle /*clientHandle*/, AbstrMsgGenerator* ach) {
assert(IsMainThread());
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
reinterpret_cast<MainWindow*>(clientHandle)->begin_timing(ach);
auto mw = MainWindow::TheOne();
if (mw)
mw->begin_timing(ach);
}

void OnEndWaiting(void* clientHandle, AbstrMsgGenerator* ach) {
void OnEndWaiting(ClientHandle /*clientHandle*/, AbstrMsgGenerator* ach) {
QGuiApplication::restoreOverrideCursor();
reinterpret_cast<MainWindow*>(clientHandle)->end_timing(ach);
auto mw = MainWindow::TheOne();
if (mw)
mw->end_timing(ach);
}

void MainWindow::setupDmsCallbacks() {
Expand Down
4 changes: 2 additions & 2 deletions qtgui/exe/src/DmsMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ public slots:
void on_status_msg_changed(const QString& msg);
void updateStatusMessage();

void begin_timing(AbstrMsgGenerator* ach); friend void OnStartWaiting(void* clientHandle, AbstrMsgGenerator* ach);
void end_timing(AbstrMsgGenerator* ach); friend void OnEndWaiting (void* clientHandle, AbstrMsgGenerator* ach);
void begin_timing(AbstrMsgGenerator* ach); friend void OnStartWaiting(ClientHandle clientHandle, AbstrMsgGenerator* ach);
void end_timing(AbstrMsgGenerator* ach); friend void OnEndWaiting (ClientHandle clientHandle, AbstrMsgGenerator* ach);


static void OnViewAction(const TreeItem* tiContext, CharPtr sAction, Int32 nCode, Int32 x, Int32 y, bool doAddHistory, bool isUrl, bool mustOpenDetailsPage);
Expand Down
2 changes: 1 addition & 1 deletion qtgui/exe/src/DmsViewArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ LPCWSTR RegisterViewAreaWindowClass(HINSTANCE instance) {
return className;
}

void DMS_CONV OnStatusText(void* clientHandle, SeverityTypeID st, CharPtr msg) {
void DMS_CONV OnStatusText(ClientHandle clientHandle, SeverityTypeID st, CharPtr msg) {
auto* dva = reinterpret_cast<QDmsViewArea*>(clientHandle);
assert(dva);
if (st == SeverityTypeID::ST_MajorTrace) {
Expand Down
2 changes: 2 additions & 0 deletions shv/dll/src/Controllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ void InfoController::SelectFocusElem(LayerSet* ls, const CrdPoint& worldPoint, E

if (lButtonUp || lButtonDblClk)
{
ObjectMsgGenerator thisMsgGenerator(nullptr, "SelectPoint");
Waiter waiter(&thisMsgGenerator);
GraphicLayer* layer = ls->GetActiveLayer();
if (layer)
SelectPoint(layer, worldPoint, eventID);
Expand Down
9 changes: 7 additions & 2 deletions shv/dll/src/Waiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ void Waiter::end()
return;

for (const auto& we : s_WaitingCallbacks)
if (std::get<1>(we))
std::get<1>(we)(std::get<2>(we), m_ContextGenerator);
{
auto onEndWaitingFunc = std::get<1>(we);
if (!onEndWaitingFunc)
continue;
auto clientHandle = std::get<2>(we);
onEndWaitingFunc(clientHandle, m_ContextGenerator);
}
SetBusy(false);
}

Expand Down

0 comments on commit 02832d8

Please sign in to comment.