mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 11:26:11 +00:00
Convert from Rizin commands to the API for w
(#2926)
This commit is contained in:
parent
861c784600
commit
de5c1a5154
@ -100,7 +100,7 @@ bool IOModesController::askCommitUnsavedChanges()
|
|||||||
if (ret == QMessageBox::Save) {
|
if (ret == QMessageBox::Save) {
|
||||||
Core()->commitWriteCache();
|
Core()->commitWriteCache();
|
||||||
} else if (ret == QMessageBox::Discard) {
|
} else if (ret == QMessageBox::Discard) {
|
||||||
Core()->cmdRaw("wcr");
|
Core()->resetWriteCache();
|
||||||
emit Core()->refreshCodeViews();
|
emit Core()->refreshCodeViews();
|
||||||
} else if (ret == QMessageBox::Cancel) {
|
} else if (ret == QMessageBox::Cancel) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -4126,18 +4126,27 @@ bool CutterCore::isIOCacheEnabled() const
|
|||||||
|
|
||||||
void CutterCore::commitWriteCache()
|
void CutterCore::commitWriteCache()
|
||||||
{
|
{
|
||||||
|
CORE_LOCK();
|
||||||
// Temporarily disable cache mode
|
// Temporarily disable cache mode
|
||||||
TempConfig tempConfig;
|
TempConfig tempConfig;
|
||||||
tempConfig.set("io.cache", false);
|
tempConfig.set("io.cache", false);
|
||||||
if (!isWriteModeEnabled()) {
|
if (!isWriteModeEnabled()) {
|
||||||
cmdRaw("oo+");
|
cmdRaw("oo+");
|
||||||
cmdRaw("wci");
|
rz_io_cache_commit(core->io, 0, UT64_MAX);
|
||||||
|
rz_core_block_read(core);
|
||||||
cmdRaw("oo");
|
cmdRaw("oo");
|
||||||
} else {
|
} 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.
|
// Enable or disable write-mode. Avoid unecessary changes if not need.
|
||||||
void CutterCore::setWriteMode(bool enabled)
|
void CutterCore::setWriteMode(bool enabled)
|
||||||
{
|
{
|
||||||
|
@ -721,6 +721,10 @@ public:
|
|||||||
* @brief Commit write cache to the file on disk.
|
* @brief Commit write cache to the file on disk.
|
||||||
*/
|
*/
|
||||||
void commitWriteCache();
|
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
|
* @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