Skip to content

Commit 801b31a

Browse files
committed
QScripts v1.2.1
- fixed crash when using idat (and QScripts is configured with PLUGIN_FIX) - minor mods
1 parent 365a098 commit 801b31a

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

qscripts.cpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ struct qscripts_chooser_t: public plugmod_t, public chooser_t
209209
private:
210210
action_manager_t am;
211211

212-
bool m_b_filemon_timer_active;
212+
bool m_b_filemon_timer_active = false;
213213
qtimer_t m_filemon_timer = nullptr;
214214
const std::regex RE_EXPANDER = std::regex(R"(\$(.+?)\$)");
215215

@@ -372,7 +372,8 @@ struct qscripts_chooser_t: public plugmod_t, public chooser_t
372372
return !selected_script.file_path.empty();
373373
}
374374

375-
bool is_monitor_active() const { return m_b_filemon_timer_active; }
375+
bool is_monitor_active() const { return m_b_filemon_timer_active; }
376+
bool is_filemon_timer_installed() const { return m_filemon_timer != nullptr; }
376377

377378
// Dynamic string expansion
378379
// ------------------------
@@ -634,7 +635,7 @@ struct qscripts_chooser_t: public plugmod_t, public chooser_t
634635

635636
// Always execute the main script even if it was not changed
636637
selected_script.invalidate();
637-
// ...and proceed with qscript logic
638+
// ...and proceed with QScript logic
638639
}
639640

640641
// Check if the active script or its dependencies are changed:
@@ -1001,6 +1002,7 @@ struct qscripts_chooser_t: public plugmod_t, public chooser_t
10011002
{
10021003
popup_names[POPUP_EDIT] = "~O~ptions";
10031004
setup_ui();
1005+
saveload_options(false);
10041006
}
10051007

10061008
bool activate_monitor(bool activate = true)
@@ -1078,28 +1080,23 @@ struct qscripts_chooser_t: public plugmod_t, public chooser_t
10781080
}
10791081
}
10801082

1081-
bool start_monitor()
1083+
bool install_filemon_timer()
10821084
{
1083-
// Load the options
1084-
saveload_options(false);
1085-
1086-
// Register the monitor
1087-
m_b_filemon_timer_active = false;
10881085
m_filemon_timer = register_timer(
10891086
opt_change_interval,
10901087
s_filemon_timer_cb,
10911088
this);
1092-
return m_filemon_timer != nullptr;
1089+
return is_filemon_timer_installed();
10931090
}
1094-
1095-
void stop_monitor()
1091+
1092+
void uninstall_filemon_timer()
10961093
{
1097-
if (m_filemon_timer != nullptr)
1094+
if (is_filemon_timer_installed())
10981095
{
10991096
unregister_timer(m_filemon_timer);
11001097
m_filemon_timer = nullptr;
1101-
m_b_filemon_timer_active = false;
11021098
}
1099+
activate_monitor(false);
11031100
}
11041101

11051102
bool idaapi run(size_t arg) override
@@ -1109,6 +1106,14 @@ struct qscripts_chooser_t: public plugmod_t, public chooser_t
11091106
// Full UI run
11101107
case 0:
11111108
{
1109+
if (!is_filemon_timer_installed())
1110+
{
1111+
if (!install_filemon_timer())
1112+
msg("QScripts: failed to start the file monitor.\n");
1113+
else
1114+
msg("QScripts: file monitor started successfully.\n");
1115+
}
1116+
11121117
show();
11131118
break;
11141119
}
@@ -1139,20 +1144,17 @@ struct qscripts_chooser_t: public plugmod_t, public chooser_t
11391144

11401145
virtual ~qscripts_chooser_t()
11411146
{
1142-
stop_monitor();
1147+
uninstall_filemon_timer();
11431148
}
11441149
};
11451150

11461151
//-------------------------------------------------------------------------
11471152
plugmod_t *idaapi init(void)
11481153
{
11491154
auto plg = new qscripts_chooser_t();
1150-
if (!plg->start_monitor())
1151-
{
1152-
msg("QScripts: Failed to install monitor!\n");
1153-
delete plg;
1154-
plg = nullptr;
1155-
}
1155+
if (!plg->install_filemon_timer())
1156+
msg("QScripts: failed to install the file monitor on startup. Please invoke the UI once to attempt try again!\n");
1157+
11561158
return plg;
11571159
}
11581160

0 commit comments

Comments
 (0)