mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 20:36:09 +00:00
Convert from Rizin commands to the API for w
(#2926)
This commit is contained in:
parent
a48399f73b
commit
7d42a5c7e6
@ -100,7 +100,7 @@ bool IOModesController::askCommitUnsavedChanges()
|
||||
if (ret == QMessageBox::Save) {
|
||||
Core()->commitWriteCache();
|
||||
} else if (ret == QMessageBox::Discard) {
|
||||
Core()->cmdRaw("wcr");
|
||||
Core()->resetWriteCache();
|
||||
emit Core()->refreshCodeViews();
|
||||
} else if (ret == QMessageBox::Cancel) {
|
||||
return false;
|
||||
|
@ -4126,18 +4126,27 @@ bool CutterCore::isIOCacheEnabled() const
|
||||
|
||||
void CutterCore::commitWriteCache()
|
||||
{
|
||||
CORE_LOCK();
|
||||
// Temporarily disable cache mode
|
||||
TempConfig tempConfig;
|
||||
tempConfig.set("io.cache", false);
|
||||
if (!isWriteModeEnabled()) {
|
||||
cmdRaw("oo+");
|
||||
cmdRaw("wci");
|
||||
rz_io_cache_commit(core->io, 0, UT64_MAX);
|
||||
rz_core_block_read(core);
|
||||
cmdRaw("oo");
|
||||
} else {
|
||||
cmdRaw("wci");
|
||||
rz_io_cache_commit(core->io, 0, UT64_MAX);
|
||||
rz_core_block_read(core);
|
||||
}
|
||||
}
|
||||
|
||||
void CutterCore::resetWriteCache()
|
||||
{
|
||||
CORE_LOCK();
|
||||
rz_io_cache_reset(core->io, core->io->cached);
|
||||
}
|
||||
|
||||
// Enable or disable write-mode. Avoid unecessary changes if not need.
|
||||
void CutterCore::setWriteMode(bool enabled)
|
||||
{
|
||||
|
@ -721,6 +721,10 @@ public:
|
||||
* @brief Commit write cache to the file on disk.
|
||||
*/
|
||||
void commitWriteCache();
|
||||
/**
|
||||
* @brief Reset write cache.
|
||||
*/
|
||||
void resetWriteCache();
|
||||
|
||||
/**
|
||||
* @brief Enable or disable Write mode. When the file is opened in write mode, any changes to it
|
||||
|
Loading…
Reference in New Issue
Block a user